2011-08-28 10:58:26 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2011 Birunthan Mohanathas
|
|
|
|
|
|
|
|
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"
|
2012-11-30 14:38:40 +00:00
|
|
|
#include "../Common/MenuTemplate.h"
|
2011-08-28 10:58:26 +00:00
|
|
|
#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 "DialogManage.h"
|
2011-10-01 18:46:36 +00:00
|
|
|
#include "DialogAbout.h"
|
2011-08-28 10:58:26 +00:00
|
|
|
#include "../Version.h"
|
2012-11-12 20:02:01 +00:00
|
|
|
#include <Commdlg.h>
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
WINDOWPLACEMENT DialogManage::c_WindowPlacement = {0};
|
2013-05-31 14:28:39 +00:00
|
|
|
DialogManage* DialogManage::c_Dialog = nullptr;
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::DialogManage() : Dialog()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Destructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::~DialogManage()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-10-29 10:36:07 +00:00
|
|
|
/*
|
|
|
|
** Opens the Manage dialog by tab name.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::Open(const WCHAR* name)
|
2011-10-29 10:36:07 +00:00
|
|
|
{
|
|
|
|
int tab = 0;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
2012-10-02 14:44:47 +00:00
|
|
|
if (_wcsicmp(name, L"Layouts") == 0 ||
|
|
|
|
_wcsicmp(name, L"Themes") == 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"Settings") == 0)
|
2011-10-29 10:36:07 +00:00
|
|
|
{
|
|
|
|
tab = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Open(tab);
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
/*
|
|
|
|
** Opens the Manage dialog.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::Open(int tab)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
if (!c_Dialog)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
c_Dialog = new DialogManage();
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
c_Dialog->ShowDialogWindow(
|
|
|
|
GetString(ID_STR_MANAGERAINMETER),
|
|
|
|
0, 0, 500, 322,
|
2013-11-02 09:58:25 +00:00
|
|
|
DS_CENTER | WS_POPUP | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU,
|
2012-12-22 09:18:53 +00:00
|
|
|
WS_EX_APPWINDOW | WS_EX_CONTROLPARENT | ((*GetString(ID_STR_ISRTL) == L'1') ? WS_EX_LAYOUTRTL : 0),
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().GetWindow());
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Fake WM_NOTIFY to change tab
|
|
|
|
NMHDR nm;
|
|
|
|
nm.code = TCN_SELCHANGE;
|
2012-12-13 09:12:25 +00:00
|
|
|
nm.idFrom = Id_Tab;
|
2012-12-13 10:11:27 +00:00
|
|
|
nm.hwndFrom = c_Dialog->GetControl(Id_Tab);
|
2011-08-28 10:58:26 +00:00
|
|
|
TabCtrl_SetCurSel(nm.hwndFrom, tab);
|
|
|
|
c_Dialog->OnNotify(0, (LPARAM)&nm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Opens the Manage dialog Skins tab with skin selected.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::OpenSkin(MeterWindow* meterWindow)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
Open();
|
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
if (c_Dialog)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-06-01 13:06:36 +00:00
|
|
|
std::wstring name = meterWindow->GetFolderPath() + L'\\';
|
|
|
|
name += meterWindow->GetFileName();
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
HWND item = c_Dialog->m_TabSkins.GetControl(TabSkins::Id_SkinsTreeView);
|
2011-11-21 12:53:55 +00:00
|
|
|
c_Dialog->m_TabSkins.SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-25 17:28:15 +00:00
|
|
|
/*
|
2013-08-26 04:47:20 +00:00
|
|
|
** Opens the Manage dialog tab with parameters
|
2013-08-25 17:28:15 +00:00
|
|
|
**
|
|
|
|
*/
|
2013-08-26 04:47:20 +00:00
|
|
|
void DialogManage::Open(const WCHAR* tabName, const WCHAR* param1, const WCHAR* param2)
|
2013-08-25 17:28:15 +00:00
|
|
|
{
|
|
|
|
Open(tabName);
|
|
|
|
|
|
|
|
if (c_Dialog)
|
|
|
|
{
|
2013-08-26 04:47:20 +00:00
|
|
|
// "Skins" tab
|
2013-08-25 17:28:15 +00:00
|
|
|
if (_wcsicmp(tabName, L"Skins") == 0)
|
|
|
|
{
|
|
|
|
// |param1| represents the config (ie. "illustro\Clock")
|
|
|
|
// |param2| represents the file (ie. "Clock.ini")
|
|
|
|
|
|
|
|
std::wstring name = param1;
|
|
|
|
|
|
|
|
if (param2)
|
|
|
|
{
|
|
|
|
name += L'\\';
|
|
|
|
name += param2;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND item = c_Dialog->m_TabSkins.GetControl(TabSkins::Id_SkinsTreeView);
|
|
|
|
c_Dialog->m_TabSkins.SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
|
|
|
|
}
|
|
|
|
// Future use: Allow optional params for different tabs
|
|
|
|
//else if (_wcsicmp(tabName, L"Layouts") == 0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
/*
|
|
|
|
** Updates Skins tab.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::UpdateSkins(MeterWindow* meterWindow, bool deleted)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
if (c_Dialog && c_Dialog->m_TabSkins.IsInitialized())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
c_Dialog->m_TabSkins.Update(meterWindow, deleted);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Dialog::Tab& DialogManage::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_TabSkins;
|
|
|
|
}
|
|
|
|
else if (sel == 1)
|
|
|
|
{
|
2012-10-02 14:44:47 +00:00
|
|
|
return m_TabLayouts;
|
2012-02-21 09:03:16 +00:00
|
|
|
}
|
|
|
|
else // if (sel == 2)
|
|
|
|
{
|
|
|
|
return m_TabSettings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::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_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 DialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
// FIXME: Temporary hack.
|
|
|
|
short buttonWidth = (short)_wtoi(GetString(ID_STR_NUM_BUTTONWIDTH));
|
2012-02-14 17:00:07 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_BUTTON(Id_RefreshAllButton, ID_STR_REFRESHALL,
|
|
|
|
5, 303, buttonWidth, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_BUTTON(Id_EditSettingsButton, ID_STR_EDITSETTINGS,
|
|
|
|
buttonWidth + 9, 303, buttonWidth, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_BUTTON(Id_OpenLogButton, ID_STR_OPENLOG,
|
|
|
|
buttonWidth + buttonWidth + 13, 303, buttonWidth, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_BUTTON(Id_HelpButton, ID_STR_HELP,
|
|
|
|
389, 303, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_BUTTON(Id_CloseButton, ID_STR_CLOSE,
|
|
|
|
444, 303, 50, 14,
|
2012-12-13 10:20:14 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON, 0),
|
|
|
|
CT_TAB(Id_Tab, 0,
|
|
|
|
6, 6, 488, 293,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | TCS_FIXEDWIDTH, 0) // Last for correct tab order.
|
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_TabSkins.Create(m_Window);
|
|
|
|
m_TabLayouts.Create(m_Window);
|
|
|
|
m_TabSettings.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_SKINS);
|
2011-08-28 10:58:26 +00:00
|
|
|
TabCtrl_InsertItem(item, 0, &tci);
|
2011-09-24 09:13:13 +00:00
|
|
|
tci.pszText = GetString(ID_STR_THEMES);
|
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_SETTINGS);
|
2011-08-28 10:58:26 +00:00
|
|
|
TabCtrl_InsertItem(item, 2, &tci);
|
|
|
|
|
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);
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
item = m_TabSkins.GetControl(TabSkins::Id_FileLabel);
|
2012-12-13 09:12:25 +00:00
|
|
|
SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0);
|
|
|
|
|
2014-02-12 21:42:02 +00:00
|
|
|
if (IsWindowsVistaOrGreater())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
// Use arrows instead of plus/minus in the tree for Vista+
|
2013-05-31 14:18:52 +00:00
|
|
|
item = m_TabSkins.GetControl(TabSkins::Id_SkinsTreeView);
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowTheme(item, L"explorer", nullptr);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 05:20:36 +00:00
|
|
|
if (c_WindowPlacement.length == 0)
|
|
|
|
{
|
|
|
|
c_WindowPlacement.length = sizeof(WINDOWPLACEMENT);
|
|
|
|
GetWindowPlacement(m_Window, &c_WindowPlacement);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowPlacement(m_Window, &c_WindowPlacement);
|
|
|
|
|
2012-02-14 17:00:07 +00:00
|
|
|
return FALSE;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::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_RefreshAllButton:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().RefreshAll();
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_EditSettingsButton:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().EditSettings();
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_OpenLogButton:
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::Open();
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_CloseButton:
|
|
|
|
HandleMessage(WM_CLOSE, 0, 0);
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_HelpButton:
|
2012-11-12 20:02:01 +00:00
|
|
|
{
|
2012-11-13 14:11:43 +00:00
|
|
|
std::wstring url = L"http://docs.rainmeter.net/manual/user-interface/manage#";
|
2012-11-12 20:02:01 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab& tab = GetActiveTab();
|
2012-12-13 09:12:25 +00:00
|
|
|
if (&tab == &m_TabSkins)
|
2012-11-12 20:02:01 +00:00
|
|
|
{
|
2012-11-13 14:11:43 +00:00
|
|
|
url += L"Skins";
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|
2012-12-13 09:12:25 +00:00
|
|
|
else if (&tab == &m_TabLayouts)
|
2012-11-12 20:02:01 +00:00
|
|
|
{
|
2012-11-13 14:11:43 +00:00
|
|
|
url += L"Layouts";
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|
2012-12-13 09:12:25 +00:00
|
|
|
else // if (&tab == &m_TabSettings)
|
2012-11-12 20:02:01 +00:00
|
|
|
{
|
2012-11-13 14:11:43 +00:00
|
|
|
url += L"Settings";
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|
2012-11-13 14:11:43 +00:00
|
|
|
|
|
|
|
url += L"Tab";
|
2013-05-31 14:28:39 +00:00
|
|
|
ShellExecute(m_Window, L"open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::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_TabSkins.GetWindow(), FALSE);
|
2012-10-02 14:44:47 +00:00
|
|
|
EnableWindow(m_TabLayouts.GetWindow(), FALSE);
|
2012-02-14 17:00:07 +00:00
|
|
|
EnableWindow(m_TabSettings.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
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Skins tab
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::TabSkins::TabSkins() : Tab(),
|
2011-08-28 10:58:26 +00:00
|
|
|
m_SkinWindow(),
|
|
|
|
m_HandleCommands(false),
|
|
|
|
m_IgnoreUpdate(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSkins::Create(HWND owner)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab::CreateTabWindow(15, 30, 470, 260, owner);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
// FIXME: Temporary hack.
|
|
|
|
short labelWidth = (short)_wtoi(GetString(ID_STR_NUM_LABELWIDTH));
|
|
|
|
|
|
|
|
const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_BUTTON(Id_ActiveSkinsButton, ID_STR_ACTIVESKINS,
|
|
|
|
0, 0, 146, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_TREEVIEW(Id_SkinsTreeView, 0,
|
|
|
|
0, 18, 145, 221,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_VSCROLL, WS_EX_CLIENTEDGE),
|
|
|
|
CT_BUTTON(Id_CreateSkinPackageButton, ID_STR_CREATERMSKINPACKAGE,
|
|
|
|
0, 244, 146, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
|
|
|
|
CT_LABEL(Id_FileLabel, ID_STR_ELLIPSIS,
|
|
|
|
165, 0, 130, 14,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_LABEL(Id_ConfigLabel, 0,
|
|
|
|
165, 15, 130, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_BUTTON(Id_LoadButton, ID_STR_LOAD,
|
|
|
|
310, 0, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_BUTTON(Id_RefreshButton, ID_STR_REFRESH,
|
|
|
|
364, 0, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_BUTTON(Id_EditButton, ID_STR_EDIT,
|
|
|
|
418, 0, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
|
|
|
|
CT_LABEL(-1, ID_STR_AUTHORSC,
|
|
|
|
165, 30, 80, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_LABEL(Id_AuthorLabel, 0,
|
|
|
|
230, 30, 245, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_VERSIONSC,
|
|
|
|
165, 43, 80, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_LABEL(Id_VersionLabel, 0,
|
|
|
|
230, 43, 245, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_LICENSESC,
|
|
|
|
165, 56, 80, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | SS_NOPREFIX, 0),
|
|
|
|
CT_LABEL(Id_LicenseLabel, 0,
|
|
|
|
230, 56, 245, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_INFORMATIONSC,
|
|
|
|
165, 69, 80, 9,
|
|
|
|
WS_VISIBLE | SS_ENDELLIPSIS | SS_NOPREFIX, 0),
|
|
|
|
CT_EDIT(Id_DescriptionLabel, 0,
|
|
|
|
228, 69, 238, 64,
|
|
|
|
WS_VISIBLE | ES_MULTILINE | ES_READONLY, 0),
|
|
|
|
CT_LINKLABEL(Id_AddMetadataLink, ID_STR_ADDMETADATA,
|
|
|
|
165, 142, 150, 9,
|
|
|
|
0, 0),
|
|
|
|
|
|
|
|
CT_LINEH(-1, ID_STR_COORDINATESSC,
|
|
|
|
165, 156, 304, 1,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
|
|
|
|
CT_LABEL(-1, ID_STR_COORDINATESSC,
|
|
|
|
165, 169, labelWidth, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_EDIT(Id_XPositionEdit, 0,
|
|
|
|
165 + labelWidth, 166, 38, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, WS_EX_CLIENTEDGE),
|
|
|
|
CT_EDIT(Id_YPositionEdit, 0,
|
|
|
|
165 + labelWidth + 42, 166, 38, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, WS_EX_CLIENTEDGE),
|
|
|
|
CT_LABEL(-1, ID_STR_POSITIONSC,
|
|
|
|
165, 190, labelWidth, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_COMBOBOX(Id_ZPositionDropDownList, 0,
|
|
|
|
165 + labelWidth, 187, 80, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST | WS_VSCROLL | WS_DISABLED, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_LOADORDERSC,
|
|
|
|
165, 208, labelWidth, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_EDIT(Id_LoadOrderEdit, 0,
|
|
|
|
165 + labelWidth, 205, 80, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, WS_EX_CLIENTEDGE),
|
|
|
|
CT_LABEL(-1, ID_STR_TRANSPARENCYSC,
|
|
|
|
165, 229, labelWidth, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_COMBOBOX(Id_TransparencyDropDownList, 0,
|
|
|
|
165 + labelWidth, 226, 80, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST | WS_VSCROLL | WS_DISABLED, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_ONHOVERSC,
|
|
|
|
165, 247, labelWidth, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_COMBOBOX(Id_OnHoverDropDownList, 0,
|
|
|
|
165 + labelWidth, 244, 80, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST | WS_VSCROLL | WS_DISABLED, 0),
|
|
|
|
|
|
|
|
CT_BUTTON(Id_DisplayMonitorButton, ID_STR_DISPLAYMONITOR,
|
|
|
|
350, 166, 118, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_CHECKBOX(Id_DraggableCheckBox, ID_STR_DRAGGABLE,
|
|
|
|
350, 190, 118, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_CHECKBOX(Id_ClickThroughCheckBox, ID_STR_CLICKTHROUGH,
|
|
|
|
350, 203, 118, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_CHECKBOX(Id_KeepOnScreenCheckBox, ID_STR_KEEPONSCREEN,
|
|
|
|
350, 216, 118, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_CHECKBOX(Id_SavePositionCheckBox, ID_STR_SAVEPOSITION,
|
|
|
|
350, 229, 118, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_CHECKBOX(Id_SnapToEdgesCheckBox, ID_STR_SNAPTOEDGES,
|
|
|
|
350, 242, 118, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateControls(s_Controls, _countof(s_Controls), c_Dialog->m_Font, GetString);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSkins::Initialize()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-06-01 14:08:13 +00:00
|
|
|
BUTTON_SPLITINFO bsi;
|
|
|
|
bsi.mask = BCSIF_SIZE;
|
|
|
|
bsi.size.cx = 20;
|
|
|
|
bsi.size.cy = 14;
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_ActiveSkinsButton);
|
2013-05-31 14:18:52 +00:00
|
|
|
Dialog::SetMenuButton(item);
|
2012-06-17 13:31:16 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DisplayMonitorButton);
|
2013-05-31 14:18:52 +00:00
|
|
|
Dialog::SetMenuButton(item);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Load folder/.ini icons from shell32
|
|
|
|
HIMAGELIST hImageList = ImageList_Create(16, 16, ILC_COLOR32, 2, 10);
|
2011-12-09 08:40:19 +00:00
|
|
|
HMODULE hDLL = GetModuleHandle(L"shell32");
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
HICON hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(4), IMAGE_ICON, 16, 16, LR_SHARED);
|
|
|
|
ImageList_AddIcon(hImageList, hIcon);
|
|
|
|
hIcon = (HICON)LoadImage(hDLL, MAKEINTRESOURCE(151), IMAGE_ICON, 16, 16, LR_SHARED);
|
|
|
|
ImageList_AddIcon(hImageList, hIcon);
|
|
|
|
|
|
|
|
// Apply icons and populate tree
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_SkinsTreeView);
|
2011-08-28 10:58:26 +00:00
|
|
|
TreeView_SetImageList(item, hImageList, TVSIL_NORMAL);
|
2013-05-31 14:28:39 +00:00
|
|
|
Update(nullptr, false);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Get rid of the EDITTEXT control border
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DescriptionLabel);
|
2012-03-14 02:52:35 +00:00
|
|
|
SetWindowLongPtr(item, GWL_EXSTYLE, GetWindowLongPtr(item, GWL_EXSTYLE) &~ WS_EX_CLIENTEDGE);
|
2013-05-31 14:28:39 +00:00
|
|
|
SetWindowPos(item, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_TransparencyDropDownList);
|
2011-08-28 10:58:26 +00:00
|
|
|
ComboBox_AddString(item, L"0%");
|
|
|
|
ComboBox_AddString(item, L"10%");
|
|
|
|
ComboBox_AddString(item, L"20%");
|
|
|
|
ComboBox_AddString(item, L"30%");
|
|
|
|
ComboBox_AddString(item, L"40%");
|
|
|
|
ComboBox_AddString(item, L"50%");
|
|
|
|
ComboBox_AddString(item, L"60%");
|
|
|
|
ComboBox_AddString(item, L"70%");
|
|
|
|
ComboBox_AddString(item, L"80%");
|
|
|
|
ComboBox_AddString(item, L"90%");
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ZPositionDropDownList);
|
2011-09-24 09:13:13 +00:00
|
|
|
ComboBox_AddString(item, GetString(ID_STR_ONDESKTOP));
|
|
|
|
ComboBox_AddString(item, GetString(ID_STR_BOTTOM));
|
|
|
|
ComboBox_AddString(item, GetString(ID_STR_NORMAL));
|
|
|
|
ComboBox_AddString(item, GetString(ID_STR_TOPMOST));
|
|
|
|
ComboBox_AddString(item, GetString(ID_STR_STAYTOPMOST));
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_OnHoverDropDownList);
|
2011-09-24 09:13:13 +00:00
|
|
|
ComboBox_AddString(item, GetString(ID_STR_DONOTHING));
|
|
|
|
ComboBox_AddString(item, GetString(ID_STR_HIDE));
|
|
|
|
ComboBox_AddString(item, GetString(ID_STR_FADEIN));
|
|
|
|
ComboBox_AddString(item, GetString(ID_STR_FADEOUT));
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-11-13 15:39:12 +00:00
|
|
|
m_Initialized = true;
|
2011-08-28 10:58:26 +00:00
|
|
|
m_HandleCommands = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Updates metadata and settings when changed.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSkins::Update(MeterWindow* meterWindow, bool deleted)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-08-28 12:28:00 +00:00
|
|
|
if (meterWindow)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-09-08 23:10:41 +00:00
|
|
|
if (!deleted && m_IgnoreUpdate)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-08-28 12:28:00 +00:00
|
|
|
// Changed setting from dialog, no need to update
|
|
|
|
m_IgnoreUpdate = false;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2011-08-28 12:28:00 +00:00
|
|
|
else if (m_SkinWindow && m_SkinWindow == meterWindow)
|
|
|
|
{
|
|
|
|
// Update from currently open skin
|
|
|
|
m_HandleCommands = false;
|
|
|
|
if (deleted)
|
|
|
|
{
|
|
|
|
DisableControls();
|
2013-05-31 14:28:39 +00:00
|
|
|
m_SkinWindow = nullptr;
|
2011-08-28 12:28:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetControls();
|
|
|
|
}
|
|
|
|
m_HandleCommands = true;
|
|
|
|
}
|
2012-06-01 13:06:36 +00:00
|
|
|
else if (wcscmp(meterWindow->GetFolderPath().c_str(), m_SkinFolderPath.c_str()) == 0 &&
|
|
|
|
wcscmp(meterWindow->GetFileName().c_str(), m_SkinFileName.c_str()) == 0)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-08-28 12:28:00 +00:00
|
|
|
ReadSkin();
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-28 12:28:00 +00:00
|
|
|
else
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-08-28 12:28:00 +00:00
|
|
|
// Populate tree
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_SkinsTreeView);
|
2011-08-28 12:28:00 +00:00
|
|
|
TreeView_DeleteAllItems(item);
|
|
|
|
|
2011-11-25 19:11:46 +00:00
|
|
|
TVINSERTSTRUCT tvi = {0};
|
2012-06-01 10:05:25 +00:00
|
|
|
tvi.hInsertAfter = TVI_LAST;
|
2011-11-25 19:11:46 +00:00
|
|
|
tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
|
|
|
tvi.item.iImage = tvi.item.iSelectedImage = 0;
|
2012-06-25 08:11:05 +00:00
|
|
|
|
2013-06-16 16:14:59 +00:00
|
|
|
if (!GetRainmeter().m_SkinRegistry.IsEmpty())
|
2012-06-25 08:11:05 +00:00
|
|
|
{
|
|
|
|
PopulateTree(item, tvi);
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSkins::SetControls()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
WCHAR buffer[64];
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_EditButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_LoadButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
|
|
|
|
if (m_SkinWindow)
|
|
|
|
{
|
2011-09-24 09:13:13 +00:00
|
|
|
SetWindowText(item, GetString(ID_STR_UNLOAD));
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_RefreshButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_XPositionEdit);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(m_SkinWindow->GetX(), buffer, 10);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, buffer);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_YPositionEdit);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(m_SkinWindow->GetY(), buffer, 10);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, buffer);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DisplayMonitorButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DraggableCheckBox);
|
2013-06-13 14:20:27 +00:00
|
|
|
if (GetRainmeter().GetDisableDragging())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
Button_SetCheck(item, m_SkinWindow->GetWindowDraggable());
|
|
|
|
}
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ClickThroughCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
Button_SetCheck(item, m_SkinWindow->GetClickThrough());
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_KeepOnScreenCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
Button_SetCheck(item, m_SkinWindow->GetKeepOnScreen());
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_SavePositionCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
Button_SetCheck(item, m_SkinWindow->GetSavePosition());
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_SnapToEdgesCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
Button_SetCheck(item, m_SkinWindow->GetSnapEdges());
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_TransparencyDropDownList);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
int value = (int)(10 - m_SkinWindow->GetAlphaValue() / 25.5);
|
|
|
|
value = min(9, value);
|
|
|
|
value = max(0, value);
|
|
|
|
ComboBox_SetCurSel(item, value);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ZPositionDropDownList);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
ComboBox_SetCurSel(item, m_SkinWindow->GetWindowZPosition() + 2);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_LoadOrderEdit);
|
2011-09-08 14:39:25 +00:00
|
|
|
EnableWindow(item, TRUE);
|
2013-06-13 14:20:27 +00:00
|
|
|
_itow_s(GetRainmeter().GetLoadOrder(m_SkinFolderPath), buffer, 10);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, buffer);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_OnHoverDropDownList);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
ComboBox_SetCurSel(item, m_SkinWindow->GetWindowHide());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-24 09:13:13 +00:00
|
|
|
SetWindowText(item, GetString(ID_STR_LOAD));
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSkins::DisableControls(bool clear)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_LoadButton);
|
2011-09-24 09:13:13 +00:00
|
|
|
SetWindowText(item, GetString(ID_STR_LOAD));
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
if (clear)
|
|
|
|
{
|
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_EditButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_FileLabel);
|
2012-12-13 09:12:25 +00:00
|
|
|
SetWindowText(item, GetString(ID_STR_ELLIPSIS));
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ConfigLabel);
|
2012-12-13 09:12:25 +00:00
|
|
|
SetWindowText(item, L"");
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_AuthorLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_VersionLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_LicenseLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DescriptionLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
ShowScrollBar(item, SB_VERT, FALSE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_AddMetadataLink);
|
2011-08-28 10:58:26 +00:00
|
|
|
ShowWindow(item, SW_HIDE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
}
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_RefreshButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_XPositionEdit);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_YPositionEdit);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DisplayMonitorButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DraggableCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ClickThroughCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_KeepOnScreenCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_SavePositionCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_SnapToEdgesCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_TransparencyDropDownList);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
ComboBox_SetCurSel(item, -1);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ZPositionDropDownList);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
ComboBox_SetCurSel(item, -1);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_LoadOrderEdit);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
2011-09-08 14:39:25 +00:00
|
|
|
EnableWindow(item, FALSE);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_OnHoverDropDownList);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, FALSE);
|
|
|
|
ComboBox_SetCurSel(item, -1);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSkins::ReadSkin()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_FileLabel);
|
2012-06-01 13:06:36 +00:00
|
|
|
SetWindowText(item, m_SkinFileName.c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
PathSetDlgItemPath(m_Window, Id_ConfigLabel, m_SkinFolderPath.c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_EditButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring file = GetRainmeter().GetSkinPath() + m_SkinFolderPath;
|
2011-12-04 22:18:40 +00:00
|
|
|
file += L'\\';
|
2012-06-01 13:06:36 +00:00
|
|
|
file += m_SkinFileName;
|
2013-06-13 14:20:27 +00:00
|
|
|
m_SkinWindow = GetRainmeter().GetMeterWindowByINI(file);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (!m_SkinWindow)
|
|
|
|
{
|
|
|
|
DisableControls();
|
|
|
|
}
|
|
|
|
|
|
|
|
SetControls();
|
|
|
|
|
2011-08-28 14:08:48 +00:00
|
|
|
WCHAR* buffer = new WCHAR[MAX_LINE_LENGTH];
|
2012-09-30 15:19:17 +00:00
|
|
|
const WCHAR* fileSz = file.c_str();
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_AuthorLabel);
|
2013-05-31 14:28:39 +00:00
|
|
|
if (GetPrivateProfileString(L"Metadata", L"Author", nullptr, buffer, MAX_LINE_LENGTH, fileSz) == 0)
|
2012-09-30 15:08:23 +00:00
|
|
|
{
|
|
|
|
// For backwards compatibility.
|
2013-05-31 14:28:39 +00:00
|
|
|
GetPrivateProfileString(L"Rainmeter", L"Author", nullptr, buffer, MAX_LINE_LENGTH, fileSz);
|
2012-09-30 15:08:23 +00:00
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, buffer);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_AddMetadataLink);
|
2012-09-30 15:10:54 +00:00
|
|
|
if (GetPrivateProfileSection(L"Metadata", buffer, 8, fileSz) > 0)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
ShowWindow(item, SW_HIDE);
|
|
|
|
|
|
|
|
// Set metadata
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_VersionLabel);
|
2013-05-31 14:28:39 +00:00
|
|
|
GetPrivateProfileString(L"Metadata", L"Version", nullptr, buffer, MAX_LINE_LENGTH, fileSz);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, buffer);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_LicenseLabel);
|
2013-05-31 14:28:39 +00:00
|
|
|
GetPrivateProfileString(L"Metadata", L"License", nullptr, buffer, MAX_LINE_LENGTH, fileSz);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, buffer);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DescriptionLabel);
|
2011-08-28 14:08:48 +00:00
|
|
|
std::wstring text;
|
2013-05-31 14:28:39 +00:00
|
|
|
if (GetPrivateProfileString(L"Metadata", L"Information", nullptr, buffer, MAX_LINE_LENGTH, fileSz) > 0)
|
2011-08-28 14:08:48 +00:00
|
|
|
{
|
|
|
|
text = buffer;
|
|
|
|
}
|
|
|
|
else
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-08-28 14:08:48 +00:00
|
|
|
// For backwards compatibility
|
2013-05-31 14:28:39 +00:00
|
|
|
GetPrivateProfileString(L"Metadata", L"Description", nullptr, buffer, MAX_LINE_LENGTH, fileSz);
|
2011-08-28 14:08:48 +00:00
|
|
|
text = buffer;
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
if (GetPrivateProfileString(L"Metadata", L"Instructions", nullptr, buffer, MAX_LINE_LENGTH, fileSz) > 0)
|
2011-08-28 14:08:48 +00:00
|
|
|
{
|
|
|
|
text += L"\r\n\r\n";
|
|
|
|
text += buffer;
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Replace | with newline
|
|
|
|
std::wstring::size_type pos;
|
|
|
|
while ((pos = text.find_first_of(L'|')) != std::wstring::npos)
|
|
|
|
{
|
|
|
|
size_t count = (pos + 1 < text.length() && text[pos + 1] == L' ') ? 2 : 1;
|
|
|
|
if (text[pos - 1] == L' ')
|
|
|
|
{
|
|
|
|
--pos;
|
|
|
|
count += 1;
|
|
|
|
}
|
|
|
|
text.replace(pos, count, L"\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowText(item, text.c_str());
|
|
|
|
|
|
|
|
int lines = Edit_GetLineCount(item);
|
|
|
|
ShowScrollBar(item, SB_VERT, (BOOL)(lines > 6));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowWindow(item, SW_SHOWNORMAL);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_VersionLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_LicenseLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DescriptionLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
SetWindowText(item, L"");
|
|
|
|
ShowScrollBar(item, SB_VERT, FALSE);
|
|
|
|
}
|
2011-08-28 14:08:48 +00:00
|
|
|
|
2011-08-28 16:06:23 +00:00
|
|
|
delete [] buffer;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
std::wstring DialogManage::TabSkins::GetTreeSelectionPath(HWND tree)
|
2012-06-09 16:56:59 +00:00
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
// Get current selection name
|
|
|
|
TVITEM tvi = {0};
|
|
|
|
tvi.hItem = TreeView_GetSelection(tree);
|
|
|
|
tvi.mask = TVIF_TEXT;
|
|
|
|
tvi.pszText = buffer;
|
|
|
|
tvi.cchTextMax = MAX_PATH;
|
|
|
|
TreeView_GetItem(tree, &tvi);
|
|
|
|
|
|
|
|
std::wstring path = buffer;
|
2013-05-31 14:28:39 +00:00
|
|
|
while ((tvi.hItem = TreeView_GetParent(tree, tvi.hItem)) != nullptr)
|
2012-06-09 16:56:59 +00:00
|
|
|
{
|
|
|
|
TreeView_GetItem(tree, &tvi);
|
|
|
|
path.insert(0, 1, L'\\');
|
|
|
|
path.insert(0, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
/*
|
|
|
|
** Populates the treeview with folders and skins.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
int DialogManage::TabSkins::PopulateTree(HWND tree, TVINSERTSTRUCT& tvi, int index)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-06-16 16:14:59 +00:00
|
|
|
int initialLevel = GetRainmeter().m_SkinRegistry.GetFolder(index).level;
|
2012-06-01 10:05:25 +00:00
|
|
|
|
2013-06-16 16:14:59 +00:00
|
|
|
const size_t max = GetRainmeter().m_SkinRegistry.GetFolderCount();
|
2012-06-01 10:05:25 +00:00
|
|
|
while (index < max)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-06-16 16:14:59 +00:00
|
|
|
const auto& skinFolder = GetRainmeter().m_SkinRegistry.GetFolder(index);
|
2012-06-01 13:06:36 +00:00
|
|
|
if (skinFolder.level != initialLevel)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-06-01 10:05:25 +00:00
|
|
|
return index - 1;
|
2011-11-21 12:53:55 +00:00
|
|
|
}
|
2012-06-01 10:05:25 +00:00
|
|
|
|
|
|
|
HTREEITEM oldParent = tvi.hParent;
|
|
|
|
|
|
|
|
// Add folder
|
|
|
|
tvi.item.iImage = tvi.item.iSelectedImage = 0;
|
2012-06-01 13:06:36 +00:00
|
|
|
tvi.item.pszText = (WCHAR*)skinFolder.name.c_str();
|
2012-06-01 10:05:25 +00:00
|
|
|
tvi.hParent = TreeView_InsertItem(tree, &tvi);
|
|
|
|
|
|
|
|
// Add subfolders
|
|
|
|
if ((index + 1) < max &&
|
2013-06-16 16:14:59 +00:00
|
|
|
GetRainmeter().m_SkinRegistry.GetFolder(index + 1).level == initialLevel + 1)
|
2011-11-21 12:53:55 +00:00
|
|
|
{
|
2012-06-01 10:05:25 +00:00
|
|
|
index = PopulateTree(tree, tvi, index + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add files
|
|
|
|
tvi.item.iImage = tvi.item.iSelectedImage = 1;
|
2012-06-01 13:06:36 +00:00
|
|
|
for (int i = 0, isize = (int)skinFolder.files.size(); i < isize; ++i)
|
2012-06-01 10:05:25 +00:00
|
|
|
{
|
2012-06-01 13:06:36 +00:00
|
|
|
tvi.item.pszText = (WCHAR*)skinFolder.files[i].c_str();
|
2011-11-25 19:11:46 +00:00
|
|
|
TreeView_InsertItem(tree, &tvi);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2012-06-01 10:05:25 +00:00
|
|
|
|
|
|
|
tvi.hParent = oldParent;
|
|
|
|
|
|
|
|
++index;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2012-06-01 10:05:25 +00:00
|
|
|
|
|
|
|
return index;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Selects an item in the treeview.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSkins::SelectTreeItem(HWND tree, HTREEITEM item, LPCWSTR name)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
TVITEM tvi = {0};
|
|
|
|
tvi.mask = TVIF_TEXT;
|
|
|
|
tvi.hItem = item;
|
|
|
|
tvi.pszText = buffer;
|
|
|
|
|
2011-11-21 12:53:55 +00:00
|
|
|
const WCHAR* pos = wcschr(name, L'\\');
|
|
|
|
if (pos)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-07-19 06:01:24 +00:00
|
|
|
const int folderLen = (int)(pos - name);
|
2013-05-31 14:28:39 +00:00
|
|
|
tvi.cchTextMax = folderLen + 1; // Length of folder name plus 1 for nullptr
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Find and expand the folder
|
|
|
|
do
|
|
|
|
{
|
|
|
|
TreeView_GetItem(tree, &tvi);
|
2011-11-21 12:53:55 +00:00
|
|
|
if (wcsncmp(buffer, name, folderLen) == 0)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
if ((item = TreeView_GetChild(tree, tvi.hItem)) != nullptr)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
TreeView_Expand(tree, tvi.hItem, TVE_EXPAND);
|
2013-08-25 17:28:15 +00:00
|
|
|
TreeView_Select(tree, tvi.hItem, TVGN_CARET);
|
2011-11-21 12:53:55 +00:00
|
|
|
++pos; // Skip the slash
|
|
|
|
SelectTreeItem(tree, item, pos);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-31 14:28:39 +00:00
|
|
|
while ((tvi.hItem = TreeView_GetNextSibling(tree, tvi.hItem)) != nullptr);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-21 12:53:55 +00:00
|
|
|
tvi.cchTextMax = MAX_PATH;
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
// Find and select the file
|
|
|
|
do
|
|
|
|
{
|
|
|
|
TreeView_GetItem(tree, &tvi);
|
|
|
|
if (wcscmp(buffer, name) == 0)
|
|
|
|
{
|
|
|
|
TreeView_Select(tree, tvi.hItem, TVGN_CARET);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-31 14:28:39 +00:00
|
|
|
while ((tvi.hItem = TreeView_GetNextSibling(tree, tvi.hItem)) != nullptr);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::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);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
2012-12-13 09:12:25 +00:00
|
|
|
return OnNotify(wParam, lParam);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::TabSkins::OnCommand(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-09-08 14:39:25 +00:00
|
|
|
if (!m_HandleCommands)
|
|
|
|
{
|
2012-11-13 15:39:12 +00:00
|
|
|
// Values are being changed/reset, no need to apply changes.
|
2011-09-08 14:39:25 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_ActiveSkinsButton:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
HMENU menu = CreatePopupMenu();
|
|
|
|
|
|
|
|
// Add active skins to menu
|
2013-06-13 14:20:27 +00:00
|
|
|
std::map<std::wstring, MeterWindow*>::const_iterator iter = GetRainmeter().GetAllMeterWindows().begin();
|
2011-08-28 10:58:26 +00:00
|
|
|
int index = 0;
|
2013-06-13 14:20:27 +00:00
|
|
|
for ( ; iter != GetRainmeter().GetAllMeterWindows().end(); ++iter)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-06-01 13:06:36 +00:00
|
|
|
std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
|
|
|
|
name += ((*iter).second)->GetFileName();
|
2011-08-28 10:58:26 +00:00
|
|
|
InsertMenu(menu, index, MF_BYPOSITION, ID_CONFIG_FIRST + index, name.c_str());
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
|
2011-09-23 16:28:38 +00:00
|
|
|
if (index > 0)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-09-23 16:28:38 +00:00
|
|
|
RECT r;
|
|
|
|
GetWindowRect((HWND)lParam, &r);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2011-09-23 16:28:38 +00:00
|
|
|
// Show context menu
|
|
|
|
TrackPopupMenu(
|
|
|
|
menu,
|
|
|
|
TPM_RIGHTBUTTON | TPM_LEFTALIGN,
|
2012-01-28 16:47:26 +00:00
|
|
|
(*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left,
|
2011-09-23 16:28:38 +00:00
|
|
|
--r.bottom,
|
|
|
|
0,
|
|
|
|
m_Window,
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr
|
2011-09-23 16:28:38 +00:00
|
|
|
);
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
DestroyMenu(menu);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_CreateSkinPackageButton:
|
2012-06-24 15:10:58 +00:00
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring file = GetRainmeter().GetPath() + L"SkinInstaller.exe";
|
2013-05-31 14:18:52 +00:00
|
|
|
CommandHandler::RunFile(file.c_str(), L"/Packager");
|
2012-06-24 15:10:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_LoadButton:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
if (!m_SkinWindow)
|
|
|
|
{
|
2011-09-08 23:10:41 +00:00
|
|
|
// Skin not active, load
|
2013-06-16 16:14:59 +00:00
|
|
|
const SkinRegistry::Indexes indexes =
|
|
|
|
GetRainmeter().m_SkinRegistry.FindIndexes(m_SkinFolderPath, m_SkinFileName);
|
|
|
|
if (indexes.IsValid())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-03-10 10:17:15 +00:00
|
|
|
m_HandleCommands = false;
|
2013-06-16 16:14:59 +00:00
|
|
|
GetRainmeter().ActivateSkin(indexes.folder, indexes.file);
|
2013-03-10 10:17:15 +00:00
|
|
|
m_HandleCommands = true;
|
2011-09-08 14:39:25 +00:00
|
|
|
|
|
|
|
// Fake selection change to update controls
|
|
|
|
NMHDR nm;
|
|
|
|
nm.code = TVN_SELCHANGED;
|
2012-12-13 09:12:25 +00:00
|
|
|
nm.idFrom = Id_SkinsTreeView;
|
2012-12-13 10:11:27 +00:00
|
|
|
nm.hwndFrom = GetControl(Id_SkinsTreeView);
|
2011-09-08 14:39:25 +00:00
|
|
|
OnNotify(0, (LPARAM)&nm);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_HandleCommands = false;
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().DeactivateSkin(m_SkinWindow, -1);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_RefreshButton:
|
2011-09-24 13:04:44 +00:00
|
|
|
if (m_SkinWindow)
|
|
|
|
{
|
|
|
|
m_SkinWindow->Refresh(false);
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_EditButton:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().EditSkinFile(m_SkinFolderPath, m_SkinFileName);
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_XPositionEdit:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
{
|
|
|
|
WCHAR buffer[32];
|
2011-09-08 14:39:25 +00:00
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
int x = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
|
|
|
|
m_SkinWindow->MoveWindow(x, m_SkinWindow->GetY());
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2011-09-08 14:39:25 +00:00
|
|
|
if (x > m_SkinWindow->GetX())
|
|
|
|
{
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(m_SkinWindow->GetX(), buffer, 10);
|
2011-09-08 14:39:25 +00:00
|
|
|
Edit_SetText((HWND)lParam, buffer);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_YPositionEdit:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
{
|
|
|
|
WCHAR buffer[32];
|
2011-09-08 14:39:25 +00:00
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
int y = (GetWindowText((HWND)lParam, buffer, 32) > 0) ? _wtoi(buffer) : 0;
|
|
|
|
m_SkinWindow->MoveWindow(m_SkinWindow->GetX(), y);
|
|
|
|
|
|
|
|
if (y > m_SkinWindow->GetY())
|
|
|
|
{
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(m_SkinWindow->GetY(), buffer, 10);
|
2011-09-08 14:39:25 +00:00
|
|
|
Edit_SetText((HWND)lParam, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_LoadOrderEdit:
|
2011-09-08 14:39:25 +00:00
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
{
|
|
|
|
if (m_IgnoreUpdate)
|
|
|
|
{
|
|
|
|
// To avoid infinite loop after setting value below
|
|
|
|
m_IgnoreUpdate = false;
|
|
|
|
}
|
|
|
|
else
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-09-08 14:39:25 +00:00
|
|
|
// Convert text to number and set it to get rid of extra chars
|
2011-10-07 17:36:33 +00:00
|
|
|
WCHAR buffer[32];
|
|
|
|
int len = GetWindowText((HWND)lParam, buffer, 32);
|
|
|
|
if ((len == 0) || (len == 1 && buffer[0] == L'-'))
|
|
|
|
{
|
|
|
|
// Ignore if empty or if - is only char
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get selection
|
|
|
|
DWORD sel = Edit_GetSel((HWND)lParam);
|
|
|
|
|
|
|
|
// Reset value (to get rid of invalid chars)
|
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
int value = _wtoi(buffer);
|
2011-10-09 08:01:31 +00:00
|
|
|
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(value, buffer, 10);
|
2011-10-09 08:01:31 +00:00
|
|
|
SetWindowText((HWND)lParam, buffer);
|
2011-09-08 14:39:25 +00:00
|
|
|
|
2011-10-07 17:36:33 +00:00
|
|
|
// Reset selection
|
|
|
|
Edit_SetSel((HWND)lParam, LOWORD(sel), HIWORD(sel));
|
2011-09-08 14:39:25 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
WritePrivateProfileString(m_SkinFolderPath.c_str(), L"LoadOrder", buffer, GetRainmeter().GetIniFile().c_str());
|
2013-06-16 16:14:59 +00:00
|
|
|
const SkinRegistry::Indexes indexes = GetRainmeter().m_SkinRegistry.FindIndexes(
|
|
|
|
m_SkinWindow->GetFolderPath(), m_SkinWindow->GetFileName());
|
|
|
|
if (indexes.IsValid())
|
2011-09-08 23:10:41 +00:00
|
|
|
{
|
2013-06-16 16:14:59 +00:00
|
|
|
GetRainmeter().SetLoadOrder(indexes.folder, value);
|
2011-09-08 14:39:25 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
std::multimap<int, MeterWindow*> windows;
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().GetMeterWindowsByLoadOrder(windows);
|
2011-09-08 14:39:25 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
System::PrepareHelperWindow();
|
2011-09-08 14:39:25 +00:00
|
|
|
|
2011-09-08 23:10:41 +00:00
|
|
|
// Reorder window z-position to reflect load order
|
2013-05-31 14:18:52 +00:00
|
|
|
std::multimap<int, MeterWindow*>::const_iterator iter = windows.begin();
|
2011-09-08 23:10:41 +00:00
|
|
|
for ( ; iter != windows.end(); ++iter)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
MeterWindow* mw = (*iter).second;
|
2011-09-08 23:10:41 +00:00
|
|
|
mw->ChangeZPos(mw->GetWindowZPosition(), true);
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_DisplayMonitorButton:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-11-30 14:38:40 +00:00
|
|
|
static const MenuTemplate s_Menu[] =
|
|
|
|
{
|
|
|
|
MENU_ITEM(IDM_SKIN_MONITOR_PRIMARY, ID_STR_USEDEFAULTMONITOR),
|
|
|
|
MENU_ITEM(ID_MONITOR_FIRST, ID_STR_VIRTUALSCREEN),
|
|
|
|
MENU_SEPARATOR(),
|
|
|
|
MENU_SEPARATOR(),
|
|
|
|
MENU_ITEM(IDM_SKIN_MONITOR_AUTOSELECT, ID_STR_AUTOSELECTMONITOR)
|
|
|
|
};
|
|
|
|
|
|
|
|
HMENU menu = MenuTemplate::CreateMenu(s_Menu, _countof(s_Menu), GetString);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (menu)
|
|
|
|
{
|
2013-06-16 16:54:22 +00:00
|
|
|
ContextMenu::CreateMonitorMenu(menu, m_SkinWindow);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
RECT r;
|
|
|
|
GetWindowRect((HWND)lParam, &r);
|
|
|
|
|
|
|
|
// Show context menu
|
|
|
|
TrackPopupMenu(
|
2012-11-30 14:38:40 +00:00
|
|
|
menu,
|
2011-08-28 10:58:26 +00:00
|
|
|
TPM_RIGHTBUTTON | TPM_LEFTALIGN,
|
2012-01-28 16:47:26 +00:00
|
|
|
(*GetString(ID_STR_ISRTL) == L'1') ? r.right : r.left,
|
2011-08-28 10:58:26 +00:00
|
|
|
--r.bottom,
|
|
|
|
0,
|
|
|
|
m_Window,
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr
|
2011-08-28 10:58:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
DestroyMenu(menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_DraggableCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
m_SkinWindow->SetWindowDraggable(!m_SkinWindow->GetWindowDraggable());
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_ClickThroughCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
m_SkinWindow->SetClickThrough(!m_SkinWindow->GetClickThrough());
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_KeepOnScreenCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
m_SkinWindow->SetKeepOnScreen(!m_SkinWindow->GetKeepOnScreen());
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_SavePositionCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
m_SkinWindow->SetSavePosition(!m_SkinWindow->GetSavePosition());
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_SnapToEdgesCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
m_SkinWindow->SetSnapEdges(!m_SkinWindow->GetSnapEdges());
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_ZPositionDropDownList:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
ZPOSITION zpos = (ZPOSITION)(ComboBox_GetCurSel((HWND)lParam) - 2);
|
2011-09-30 16:49:49 +00:00
|
|
|
m_SkinWindow->SetWindowZPosition(zpos);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_TransparencyDropDownList:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
m_IgnoreUpdate = true;
|
2012-02-21 09:03:16 +00:00
|
|
|
int sel = ComboBox_GetCurSel((HWND)lParam) + IDM_SKIN_TRANSPARENCY_0;
|
2011-08-28 10:58:26 +00:00
|
|
|
SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, sel, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_OnHoverDropDownList:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
m_IgnoreUpdate = true;
|
|
|
|
HIDEMODE hide = (HIDEMODE)ComboBox_GetCurSel((HWND)lParam);
|
|
|
|
m_SkinWindow->SetWindowHide(hide);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-02-21 09:03:16 +00:00
|
|
|
case IDM_MANAGESKINSMENU_EXPAND:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND tree = GetControl(Id_SkinsTreeView);
|
2011-08-28 10:58:26 +00:00
|
|
|
HTREEITEM item = TreeView_GetSelection(tree);
|
|
|
|
TreeView_Expand(tree, item, TVE_TOGGLE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-02-21 09:03:16 +00:00
|
|
|
case IDM_MANAGESKINSMENU_OPENFOLDER:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND tree = GetControl(Id_SkinsTreeView);
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().OpenSkinFolder(GetTreeSelectionPath(tree));
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (wParam >= ID_CONFIG_FIRST && wParam <= ID_CONFIG_LAST)
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
std::map<std::wstring, MeterWindow*>::const_iterator iter = GetRainmeter().GetAllMeterWindows().begin();
|
2011-08-28 10:58:26 +00:00
|
|
|
int index = (int)wParam - ID_CONFIG_FIRST;
|
|
|
|
int i = 0;
|
2013-06-13 14:20:27 +00:00
|
|
|
for ( ; iter != GetRainmeter().GetAllMeterWindows().end(); ++iter)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
if (i == index)
|
|
|
|
{
|
2012-06-01 13:06:36 +00:00
|
|
|
std::wstring name = ((*iter).second)->GetFolderPath() + L'\\';
|
|
|
|
name += ((*iter).second)->GetFileName();
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_SkinsTreeView);
|
2011-08-28 10:58:26 +00:00
|
|
|
SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
2012-02-21 09:03:16 +00:00
|
|
|
else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT ||
|
|
|
|
wParam == IDM_SKIN_MONITOR_PRIMARY ||
|
2011-08-28 10:58:26 +00:00
|
|
|
wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
|
|
|
|
{
|
2011-10-03 22:39:24 +00:00
|
|
|
if (m_SkinWindow)
|
|
|
|
{
|
|
|
|
SendMessage(m_SkinWindow->GetWindow(), WM_COMMAND, wParam, 0);
|
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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 DialogManage::TabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
LPNMHDR nm = (LPNMHDR)lParam;
|
|
|
|
switch (nm->code)
|
|
|
|
{
|
|
|
|
case NM_CLICK:
|
2012-12-13 09:12:25 +00:00
|
|
|
if (nm->idFrom == Id_AddMetadataLink)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring file = GetRainmeter().GetSkinPath() + m_SkinFolderPath;
|
2011-12-04 22:18:40 +00:00
|
|
|
file += L'\\';
|
2012-06-01 13:06:36 +00:00
|
|
|
file += m_SkinFileName;
|
2012-09-30 15:08:23 +00:00
|
|
|
const WCHAR* str = L"\r\n" // Hack to add below [Rainmeter].
|
|
|
|
L"[Metadata]\r\n"
|
|
|
|
L"Name=\r\n"
|
2012-09-30 15:31:00 +00:00
|
|
|
L"Author=\r\n"
|
2012-09-30 15:08:23 +00:00
|
|
|
L"Information=\r\n"
|
|
|
|
L"License=\r\n"
|
|
|
|
L"Version";
|
|
|
|
WritePrivateProfileString(L"Rainmeter", str, L"", file.c_str());
|
2012-12-13 09:12:25 +00:00
|
|
|
SendMessage(m_Window, WM_COMMAND, MAKEWPARAM(Id_EditButton, 0), 0);
|
2011-08-28 10:58:26 +00:00
|
|
|
ShowWindow(nm->hwndFrom, SW_HIDE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NM_DBLCLK:
|
2012-12-13 09:12:25 +00:00
|
|
|
if (nm->idFrom == Id_SkinsTreeView && !m_SkinFileName.empty())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
OnCommand(MAKEWPARAM(Id_LoadButton, 0), 0);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NM_RCLICK:
|
2012-12-13 09:12:25 +00:00
|
|
|
if (nm->idFrom == Id_SkinsTreeView)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
POINT pt = System::GetCursorPosition();
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
TVHITTESTINFO ht;
|
|
|
|
ht.pt = pt;
|
|
|
|
ScreenToClient(nm->hwndFrom, &ht.pt);
|
|
|
|
|
|
|
|
if (TreeView_HitTest(nm->hwndFrom, &ht) && !(ht.flags & TVHT_NOWHERE))
|
|
|
|
{
|
|
|
|
TreeView_SelectItem(nm->hwndFrom, ht.hItem);
|
|
|
|
|
|
|
|
TVITEM tvi = {0};
|
|
|
|
tvi.hItem = TreeView_GetSelection(nm->hwndFrom);
|
|
|
|
tvi.mask = TVIF_STATE;
|
|
|
|
|
2012-11-30 14:38:40 +00:00
|
|
|
if (TreeView_GetItem(nm->hwndFrom, &tvi))
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
HMENU menu = nullptr;
|
2011-08-28 16:47:14 +00:00
|
|
|
MENUITEMINFO mii = {0};
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFO);
|
|
|
|
mii.fMask = MIIM_STRING;
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
if (m_SkinFileName.empty())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-11-30 14:38:40 +00:00
|
|
|
// Folder menu.
|
|
|
|
static const MenuTemplate s_Menu[] =
|
|
|
|
{
|
|
|
|
MENU_ITEM(IDM_MANAGESKINSMENU_EXPAND, ID_STR_EXPAND),
|
|
|
|
MENU_ITEM(IDM_MANAGESKINSMENU_OPENFOLDER, ID_STR_OPENFOLDER),
|
|
|
|
};
|
|
|
|
|
|
|
|
menu = MenuTemplate::CreateMenu(s_Menu, _countof(s_Menu), GetString);
|
|
|
|
SetMenuDefaultItem(menu, IDM_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
if (tvi.state & TVIS_EXPANDED)
|
|
|
|
{
|
2011-09-24 09:13:13 +00:00
|
|
|
mii.dwTypeData = GetString(ID_STR_COLLAPSE);
|
2012-11-30 14:38:40 +00:00
|
|
|
SetMenuItemInfo(menu, IDM_MANAGESKINSMENU_EXPAND, MF_BYCOMMAND, &mii);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-30 14:38:40 +00:00
|
|
|
// Skin menu.
|
|
|
|
static const MenuTemplate s_Menu[] =
|
|
|
|
{
|
|
|
|
MENU_ITEM(IDM_MANAGESKINSMENU_LOAD, ID_STR_LOAD),
|
|
|
|
MENU_ITEM(IDM_MANAGESKINSMENU_REFRESH, ID_STR_REFRESH),
|
|
|
|
MENU_ITEM(IDM_MANAGESKINSMENU_EDIT, ID_STR_EDIT),
|
|
|
|
};
|
|
|
|
|
|
|
|
menu = MenuTemplate::CreateMenu(s_Menu, _countof(s_Menu), GetString);
|
|
|
|
SetMenuDefaultItem(menu, IDM_MANAGESKINSMENU_LOAD, MF_BYCOMMAND);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
if (m_SkinWindow)
|
|
|
|
{
|
2011-09-24 09:13:13 +00:00
|
|
|
mii.dwTypeData = GetString(ID_STR_UNLOAD);
|
2012-11-30 14:38:40 +00:00
|
|
|
SetMenuItemInfo(menu, IDM_MANAGESKINSMENU_LOAD, MF_BYCOMMAND, &mii);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-30 14:38:40 +00:00
|
|
|
EnableMenuItem(menu, IDM_MANAGESKINSMENU_REFRESH, MF_BYCOMMAND | MF_GRAYED);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show context menu
|
|
|
|
TrackPopupMenu(
|
2012-11-30 14:38:40 +00:00
|
|
|
menu,
|
2011-08-28 10:58:26 +00:00
|
|
|
TPM_RIGHTBUTTON | TPM_LEFTALIGN,
|
|
|
|
pt.x,
|
|
|
|
pt.y,
|
|
|
|
0,
|
|
|
|
m_Window,
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr
|
2011-08-28 10:58:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
DestroyMenu(menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TVN_SELCHANGED:
|
2012-12-13 09:12:25 +00:00
|
|
|
if (nm->idFrom == Id_SkinsTreeView)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
m_SkinWindow = nullptr;
|
2012-06-01 13:06:36 +00:00
|
|
|
m_SkinFileName.clear();
|
|
|
|
m_SkinFolderPath.clear();
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Temporarily disable handling commands
|
|
|
|
m_HandleCommands = false;
|
|
|
|
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
// Get current selection name
|
|
|
|
TVITEM tvi = {0};
|
|
|
|
tvi.hItem = TreeView_GetSelection(nm->hwndFrom);
|
|
|
|
tvi.mask = TVIF_TEXT | TVIF_CHILDREN;
|
|
|
|
tvi.pszText = buffer;
|
|
|
|
tvi.cchTextMax = MAX_PATH;
|
|
|
|
TreeView_GetItem(nm->hwndFrom, &tvi);
|
|
|
|
|
|
|
|
if (tvi.cChildren == 0)
|
|
|
|
{
|
|
|
|
// Current selection is file
|
2012-06-01 13:06:36 +00:00
|
|
|
m_SkinFileName = buffer;
|
2011-08-28 10:58:26 +00:00
|
|
|
tvi.mask = TVIF_TEXT;
|
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
// Loop through parents to get skin folder
|
|
|
|
m_SkinFolderPath.clear();
|
2013-05-31 14:28:39 +00:00
|
|
|
while ((tvi.hItem = TreeView_GetParent(nm->hwndFrom, tvi.hItem)) != nullptr)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
TreeView_GetItem(nm->hwndFrom, &tvi);
|
2012-06-01 13:06:36 +00:00
|
|
|
m_SkinFolderPath.insert(0, 1, L'\\');
|
|
|
|
m_SkinFolderPath.insert(0, buffer);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
m_SkinFolderPath.resize(m_SkinFolderPath.length() - 1); // Get rid of trailing slash
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
ReadSkin();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DisableControls(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_HandleCommands = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
//
|
2012-10-02 14:44:47 +00:00
|
|
|
// Layouts tab
|
2011-08-28 10:58:26 +00:00
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::TabLayouts::TabLayouts() : Tab()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabLayouts::Create(HWND owner)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab::CreateTabWindow(15, 30, 470, 260, owner);
|
2012-12-13 09:12:25 +00:00
|
|
|
|
|
|
|
static const ControlTemplate::Control s_Controls[] =
|
|
|
|
{
|
|
|
|
CT_GROUPBOX(-1, ID_STR_SAVENEWTHEME,
|
|
|
|
0, 0, 230, 150,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_THEMEDESCRIPTION,
|
|
|
|
6, 16, 205, 44,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_CHECKBOX(Id_SaveEmptyThemeCheckBox, ID_STR_SAVEASEMPTYTHEME,
|
|
|
|
6, 70, 220, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_ExcludeUnusedSkinsCheckBox, ID_STR_EXCLUDEUNUSEDSKINS,
|
|
|
|
6, 83, 220, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_IncludeWallpaperCheckBox, ID_STR_INCLUDEWALLPAPER,
|
|
|
|
6, 96, 220, 9,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_NAMESC,
|
|
|
|
6, 115, 100, 9,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_EDIT(Id_NameLabel, 0,
|
|
|
|
6, 128, 162, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP, WS_EX_CLIENTEDGE),
|
|
|
|
CT_BUTTON(Id_SaveButton, ID_STR_SAVE,
|
|
|
|
172, 128, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
|
|
|
|
CT_GROUPBOX(-1, ID_STR_SAVEDTHEMES,
|
|
|
|
238, 0, 230, 150,
|
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_LISTBOX(Id_List, 0,
|
|
|
|
244, 16, 160, 125,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | LBS_SORT | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT, WS_EX_CLIENTEDGE),
|
|
|
|
CT_BUTTON(Id_LoadButton, ID_STR_LOAD,
|
|
|
|
410, 16, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_BUTTON(Id_EditButton, ID_STR_EDIT,
|
|
|
|
410, 34, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0),
|
|
|
|
CT_BUTTON(Id_DeleteButton, ID_STR_DELETE,
|
|
|
|
410, 52, 50, 14,
|
|
|
|
WS_VISIBLE | WS_TABSTOP | WS_DISABLED, 0)
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateControls(s_Controls, _countof(s_Controls), c_Dialog->m_Font, GetString);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabLayouts::Initialize()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_List);
|
2013-06-13 14:20:27 +00:00
|
|
|
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
|
2013-12-23 19:42:31 +00:00
|
|
|
for (size_t i = 0, isize = layouts.size(); i < isize; ++i)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-10-02 14:44:47 +00:00
|
|
|
ListBox_AddString(item, layouts[i].c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
2012-11-13 15:39:12 +00:00
|
|
|
|
|
|
|
m_Initialized = true;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::TabLayouts::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);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::TabLayouts::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_SaveEmptyThemeCheckBox:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
BOOL state = !(Button_GetCheck((HWND)lParam) == BST_CHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_ExcludeUnusedSkinsCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, state);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_IncludeWallpaperCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, state);
|
|
|
|
Button_SetCheck(item, BST_UNCHECKED);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_NameLabel:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
{
|
2011-09-18 07:38:14 +00:00
|
|
|
WCHAR buffer[32];
|
2011-12-09 08:40:19 +00:00
|
|
|
int len = Edit_GetText((HWND)lParam, buffer, 32);
|
2011-09-18 07:38:14 +00:00
|
|
|
|
2012-06-15 08:43:48 +00:00
|
|
|
// Disable save button if no text or if backup
|
|
|
|
BOOL state = (len > 0 && _wcsicmp(buffer, L"@Backup") != 0);
|
2012-12-13 10:11:27 +00:00
|
|
|
EnableWindow(GetControl(Id_SaveButton), state);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_List:
|
2011-08-28 10:58:26 +00:00
|
|
|
if (HIWORD(wParam) == LBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
// Ignore clicks that don't hit items
|
|
|
|
if (ListBox_GetCurSel((HWND)lParam) != LB_ERR)
|
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_LoadButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_DeleteButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_EditButton);
|
2011-08-28 10:58:26 +00:00
|
|
|
EnableWindow(item, TRUE);
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_List);
|
2011-08-28 10:58:26 +00:00
|
|
|
int sel = ListBox_GetCurSel(item);
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_NameLabel);
|
2012-10-02 14:44:47 +00:00
|
|
|
Edit_SetText(item, layouts[sel].c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_SaveButton:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_NameLabel);
|
2011-08-28 10:58:26 +00:00
|
|
|
Edit_GetText(item, buffer, MAX_PATH);
|
|
|
|
|
2012-10-02 14:44:47 +00:00
|
|
|
std::wstring layout = buffer;
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring path = GetRainmeter().GetLayoutPath();
|
2012-05-23 17:19:44 +00:00
|
|
|
CreateDirectory(path.c_str(), 0);
|
|
|
|
|
2012-10-02 14:44:47 +00:00
|
|
|
path += layout;
|
2011-08-28 10:58:26 +00:00
|
|
|
bool alreadyExists = (_waccess(path.c_str(), 0) != -1);
|
|
|
|
if (alreadyExists)
|
|
|
|
{
|
2012-10-02 14:44:47 +00:00
|
|
|
std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, layout.c_str());
|
2013-06-13 14:20:27 +00:00
|
|
|
if (GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
// Cancel
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Make sure path exists
|
2013-05-31 14:28:39 +00:00
|
|
|
CreateDirectory(path.c_str(), nullptr);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2012-10-02 14:44:47 +00:00
|
|
|
path += L"\\Rainmeter.ini";
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_SaveEmptyThemeCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (Button_GetCheck(item) != BST_CHECKED)
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
if (!System::CopyFiles(GetRainmeter().GetIniFile(), path))
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-09-23 16:28:38 +00:00
|
|
|
std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exclude unused skins
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_ExcludeUnusedSkinsCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (Button_GetCheck(item) == BST_CHECKED)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
ConfigParser parser;
|
2012-05-20 13:12:13 +00:00
|
|
|
parser.Initialize(path);
|
2011-08-28 10:58:26 +00:00
|
|
|
|
|
|
|
// Remove sections with Active=0
|
2011-11-12 15:36:05 +00:00
|
|
|
std::list<std::wstring>::const_iterator iter = parser.GetSections().begin();
|
|
|
|
for ( ; iter != parser.GetSections().end(); ++iter)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
if (parser.GetValue(*iter, L"Active", L"") == L"0")
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
WritePrivateProfileString((*iter).c_str(), nullptr, nullptr, path.c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save wallpaper
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_IncludeWallpaperCheckBox);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (Button_GetCheck(item) == BST_CHECKED)
|
|
|
|
{
|
|
|
|
// Get current wallpaper
|
|
|
|
if (SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, &buffer, 0))
|
|
|
|
{
|
|
|
|
std::wstring::size_type pos = path.find_last_of(L'\\');
|
2012-10-02 14:44:47 +00:00
|
|
|
path.replace(pos + 1, path.length() - pos - 1, L"Wallpaper.bmp");
|
2013-05-31 14:18:52 +00:00
|
|
|
System::CopyFiles((std::wstring)buffer, path);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-10-02 14:44:47 +00:00
|
|
|
// Create empty layout
|
2013-05-31 14:28:39 +00:00
|
|
|
HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
2011-08-28 10:58:26 +00:00
|
|
|
if (file == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2011-09-23 16:28:38 +00:00
|
|
|
std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str());
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR);
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alreadyExists)
|
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
item = GetControl(Id_List);
|
2012-10-02 14:44:47 +00:00
|
|
|
ListBox_AddString(item, layout.c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ScanForLayouts();
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_LoadButton:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_List);
|
2011-09-04 07:40:12 +00:00
|
|
|
int sel = ListBox_GetCurSel(item);
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().LoadLayout(GetRainmeter().m_Layouts[sel]);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_EditButton:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_List);
|
2011-08-28 10:58:26 +00:00
|
|
|
int sel = ListBox_GetCurSel(item);
|
2013-06-13 14:20:27 +00:00
|
|
|
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring args = L"\"" + GetRainmeter().GetLayoutPath();
|
2012-10-02 14:44:47 +00:00
|
|
|
args += layouts[sel];
|
|
|
|
args += L"\\Rainmeter.ini";
|
2012-08-18 06:45:16 +00:00
|
|
|
args += L'"';
|
2013-06-13 14:20:27 +00:00
|
|
|
CommandHandler::RunFile(GetRainmeter().GetSkinEditor().c_str(), args.c_str());
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_DeleteButton:
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_List);
|
2011-08-28 10:58:26 +00:00
|
|
|
int sel = ListBox_GetCurSel(item);
|
2013-06-13 14:20:27 +00:00
|
|
|
std::vector<std::wstring>& layouts = const_cast<std::vector<std::wstring>&>(GetRainmeter().GetAllLayouts());
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2012-10-02 14:44:47 +00:00
|
|
|
std::wstring text = GetFormattedString(ID_STR_THEMEDELETE, layouts[sel].c_str());
|
2013-06-13 14:20:27 +00:00
|
|
|
if (GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_ICONQUESTION | MB_YESNO) != IDYES)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
// Cancel
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring folder = GetRainmeter().GetLayoutPath();
|
2012-10-02 14:44:47 +00:00
|
|
|
folder += layouts[sel];
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
if (System::RemoveFolder(folder))
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
ListBox_DeleteString(item, sel);
|
|
|
|
|
2012-10-02 14:44:47 +00:00
|
|
|
// Remove layout from vector
|
|
|
|
std::vector<std::wstring>::iterator iter = layouts.begin();
|
|
|
|
for ( ; iter != layouts.end(); ++iter)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-10-02 14:44:47 +00:00
|
|
|
if (wcscmp(layouts[sel].c_str(), (*iter).c_str()) == 0)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-10-02 14:44:47 +00:00
|
|
|
layouts.erase(iter);
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
EnableWindow(GetControl(Id_LoadButton), FALSE);
|
|
|
|
EnableWindow(GetControl(Id_DeleteButton), FALSE);
|
|
|
|
EnableWindow(GetControl(Id_EditButton), FALSE);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Settings tab
|
|
|
|
//
|
|
|
|
// -----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Constructor.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::TabSettings::TabSettings() : Tab()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void DialogManage::TabSettings::Create(HWND owner)
|
2012-12-13 09:12:25 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
Tab::CreateTabWindow(15, 30, 470, 260, 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_GROUPBOX(-1, ID_STR_GENERAL,
|
2013-07-25 22:44:06 +00:00
|
|
|
0, 0, 468, 131,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_LANGUAGESC,
|
2013-10-06 15:16:49 +00:00
|
|
|
6, 16, 107, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_COMBOBOX(Id_LanguageDropDownList, 0,
|
2013-10-06 15:16:49 +00:00
|
|
|
107, 13, 222, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL, 0),
|
|
|
|
CT_LABEL(-1, ID_STR_EDITORSC,
|
2013-10-06 15:16:49 +00:00
|
|
|
6, 37, 107, 9,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_EDIT(Id_EditorEdit, 0,
|
2013-10-06 15:16:49 +00:00
|
|
|
107, 34, 222, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY, WS_EX_CLIENTEDGE),
|
|
|
|
CT_BUTTON(Id_EditorBrowseButton, ID_STR_ELLIPSIS,
|
2013-10-06 15:16:49 +00:00
|
|
|
333, 34, 25, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_CheckForUpdatesCheckBox, ID_STR_CHECKFORUPDATES,
|
2014-06-02 15:37:22 +00:00
|
|
|
6, 55, 200, 9,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_LockSkinsCheckBox, ID_STR_DISABLEDRAGGING,
|
2014-06-02 15:37:22 +00:00
|
|
|
6, 68, 200, 9,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_ShowTrayIconCheckBox, ID_STR_SHOWNOTIFICATIONAREAICON,
|
2014-06-02 15:37:22 +00:00
|
|
|
6, 81, 200, 9,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
2013-07-25 22:44:06 +00:00
|
|
|
CT_CHECKBOX(Id_UseD2DCheckBox, ID_STR_USED2D,
|
2014-06-02 15:37:22 +00:00
|
|
|
6, 94, 200, 9,
|
2013-07-25 22:44:06 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
2012-12-13 09:12:25 +00:00
|
|
|
CT_BUTTON(Id_ResetStatisticsButton, ID_STR_RESETSTATISTICS,
|
2013-07-25 22:44:06 +00:00
|
|
|
6, 110, buttonWidth + 20, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
|
|
|
|
CT_GROUPBOX(-1, ID_STR_LOGGING,
|
2013-07-25 22:44:06 +00:00
|
|
|
0, 138, 468, 66,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE, 0),
|
|
|
|
CT_CHECKBOX(Id_VerboseLoggingCheckbox, ID_STR_DEBUGMODE,
|
2013-07-25 22:44:06 +00:00
|
|
|
6, 154, 200, 9,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_CHECKBOX(Id_LogToFileCheckBox, ID_STR_LOGTOFILE,
|
2013-07-25 22:44:06 +00:00
|
|
|
6, 167, 200, 9,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_BUTTON(Id_ShowLogFileButton, ID_STR_SHOWLOGFILE,
|
2013-07-25 22:44:06 +00:00
|
|
|
6, 183, buttonWidth + 20, 14,
|
2012-12-13 09:12:25 +00:00
|
|
|
WS_VISIBLE | WS_TABSTOP, 0),
|
|
|
|
CT_BUTTON(Id_DeleteLogFileButton, ID_STR_DELETELOGFILE,
|
2013-07-25 22:44:06 +00:00
|
|
|
buttonWidth + 30, 183, buttonWidth + 20, 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 DialogManage::TabSettings::Initialize()
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2011-10-01 17:39:09 +00:00
|
|
|
// Scan for languages
|
2012-12-13 10:11:27 +00:00
|
|
|
HWND item = GetControl(Id_LanguageDropDownList);
|
2011-10-01 17:39:09 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring files = GetRainmeter().GetPath() + L"Languages\\*.dll";
|
2012-06-19 14:33:11 +00:00
|
|
|
WIN32_FIND_DATA fd;
|
|
|
|
HANDLE hSearch = FindFirstFile(files.c_str(), &fd);
|
|
|
|
if (hSearch != INVALID_HANDLE_VALUE)
|
2011-10-01 17:39:09 +00:00
|
|
|
{
|
2012-06-19 14:33:11 +00:00
|
|
|
do
|
2011-10-01 17:39:09 +00:00
|
|
|
{
|
2012-06-19 14:33:11 +00:00
|
|
|
WCHAR* pos = wcschr(fd.cFileName, L'.');
|
|
|
|
if (pos)
|
2011-10-01 17:39:09 +00:00
|
|
|
{
|
2012-06-19 14:33:11 +00:00
|
|
|
LCID lcid = (LCID)wcstoul(fd.cFileName, &pos, 10);
|
|
|
|
if (pos != fd.cFileName &&
|
|
|
|
_wcsicmp(pos, L".dll") == 0 &&
|
|
|
|
GetLocaleInfo(lcid, LOCALE_SENGLISHLANGUAGENAME, fd.cFileName, MAX_PATH) > 0)
|
|
|
|
{
|
|
|
|
// Strip brackets in language name
|
|
|
|
std::wstring text = fd.cFileName;
|
|
|
|
text += L" - ";
|
2011-10-01 17:39:09 +00:00
|
|
|
|
2013-10-13 15:54:55 +00:00
|
|
|
GetLocaleInfo(lcid, LOCALE_SNATIVEDISPLAYNAME, fd.cFileName, MAX_PATH);
|
2012-06-19 14:33:11 +00:00
|
|
|
text += fd.cFileName;
|
2011-10-01 17:39:09 +00:00
|
|
|
|
2012-06-19 14:33:11 +00:00
|
|
|
int index = ComboBox_AddString(item, text.c_str());
|
|
|
|
ComboBox_SetItemData(item, index, (LPARAM)lcid);
|
2011-10-01 17:39:09 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
if (lcid == GetRainmeter().GetResourceLCID())
|
2012-06-19 14:33:11 +00:00
|
|
|
{
|
|
|
|
ComboBox_SetCurSel(item, index);
|
|
|
|
}
|
2011-10-01 17:39:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-19 14:33:11 +00:00
|
|
|
while (FindNextFile(hSearch, &fd));
|
2011-10-01 17:39:09 +00:00
|
|
|
|
2012-06-19 14:33:11 +00:00
|
|
|
FindClose(hSearch);
|
|
|
|
}
|
2011-10-01 17:39:09 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
Button_SetCheck(GetControl(Id_CheckForUpdatesCheckBox), !GetRainmeter().GetDisableVersionCheck());
|
|
|
|
Button_SetCheck(GetControl(Id_LockSkinsCheckBox), GetRainmeter().GetDisableDragging());
|
2013-06-13 14:22:42 +00:00
|
|
|
Button_SetCheck(GetControl(Id_LogToFileCheckBox), GetLogger().IsLogToFile());
|
2013-06-13 14:20:27 +00:00
|
|
|
Button_SetCheck(GetControl(Id_VerboseLoggingCheckbox), GetRainmeter().GetDebug());
|
2011-08-28 10:58:26 +00:00
|
|
|
|
2013-06-13 14:22:42 +00:00
|
|
|
BOOL isLogFile = (_waccess(GetLogger().GetLogFilePath().c_str(), 0) != -1);
|
2012-12-13 10:11:27 +00:00
|
|
|
EnableWindow(GetControl(Id_ShowLogFileButton), isLogFile);
|
|
|
|
EnableWindow(GetControl(Id_DeleteLogFileButton), isLogFile);
|
2012-11-12 20:02:01 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
Edit_SetText(GetControl(Id_EditorEdit), GetRainmeter().GetSkinEditor().c_str());
|
2012-11-12 20:02:01 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
bool iconEnabled = GetRainmeter().GetTrayWindow()->IsTrayIconEnabled();
|
2012-12-13 10:11:27 +00:00
|
|
|
Button_SetCheck(GetControl(Id_ShowTrayIconCheckBox), iconEnabled);
|
2012-11-13 15:39:12 +00:00
|
|
|
|
2014-02-12 21:42:02 +00:00
|
|
|
if (IsWindowsVistaOrGreater())
|
2013-07-25 22:44:06 +00:00
|
|
|
{
|
|
|
|
Button_SetCheck(GetControl(Id_UseD2DCheckBox), GetRainmeter().GetUseD2D());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Button_Enable(GetControl(Id_UseD2DCheckBox), FALSE);
|
|
|
|
}
|
|
|
|
|
2012-11-13 15:39:12 +00:00
|
|
|
m_Initialized = true;
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::TabSettings::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);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
INT_PTR DialogManage::TabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-11-13 15:39:12 +00:00
|
|
|
if (!m_Initialized)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
switch (LOWORD(wParam))
|
|
|
|
{
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_LanguageDropDownList:
|
2011-10-01 17:39:09 +00:00
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
|
|
|
int sel = ComboBox_GetCurSel((HWND)lParam);
|
2011-11-08 19:02:31 +00:00
|
|
|
LCID lcid = (LCID)ComboBox_GetItemData((HWND)lParam, sel);
|
2013-06-13 14:20:27 +00:00
|
|
|
if (lcid != GetRainmeter().m_ResourceLCID)
|
2011-10-01 18:46:36 +00:00
|
|
|
{
|
2012-01-28 16:47:26 +00:00
|
|
|
WCHAR buffer[16];
|
|
|
|
_ultow(lcid, buffer, 10);
|
2013-06-13 14:20:27 +00:00
|
|
|
WritePrivateProfileString(L"Rainmeter", L"Language", buffer, GetRainmeter().GetIniFile().c_str());
|
2012-01-28 16:47:26 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring resource = GetRainmeter().GetPath() + L"Languages\\";
|
2012-01-28 16:47:26 +00:00
|
|
|
resource += buffer;
|
|
|
|
resource += L".dll";
|
2013-06-13 14:20:27 +00:00
|
|
|
FreeLibrary(GetRainmeter().m_ResourceInstance);
|
|
|
|
GetRainmeter().m_ResourceInstance = LoadLibraryEx(resource.c_str(), nullptr, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
|
|
|
GetRainmeter().m_ResourceLCID = lcid;
|
2012-01-28 16:47:26 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
if (DialogAbout::GetDialog())
|
2011-10-01 18:46:36 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
int sel = TabCtrl_GetCurSel(DialogAbout::GetDialog()->GetControl(DialogManage::Id_Tab));
|
|
|
|
SendMessage(DialogAbout::GetDialog()->GetWindow(), WM_CLOSE, 0, 0);
|
2012-01-28 16:47:26 +00:00
|
|
|
if (sel == 0)
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().DelayedExecuteCommand(L"!About");
|
2012-01-28 16:47:26 +00:00
|
|
|
}
|
|
|
|
else if (sel == 1)
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().DelayedExecuteCommand(L"!About Skins");
|
2012-01-28 16:47:26 +00:00
|
|
|
}
|
|
|
|
else if (sel == 2)
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().DelayedExecuteCommand(L"!About Plugins");
|
2012-01-28 16:47:26 +00:00
|
|
|
}
|
|
|
|
else //if (sel == 3)
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().DelayedExecuteCommand(L"!About Version");
|
2012-01-28 16:47:26 +00:00
|
|
|
}
|
2011-10-01 18:46:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
SendMessage(c_Dialog->GetWindow(), WM_CLOSE, 0, 0);
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().DelayedExecuteCommand(L"!Manage Settings");
|
2012-01-28 16:47:26 +00:00
|
|
|
}
|
2011-10-01 17:39:09 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_CheckForUpdatesCheckBox:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().SetDisableVersionCheck(!GetRainmeter().GetDisableVersionCheck());
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_LockSkinsCheckBox:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().SetDisableDragging(!GetRainmeter().GetDisableDragging());
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_ResetStatisticsButton:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ResetStats();
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_ShowLogFileButton:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ShowLogFile();
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_DeleteLogFileButton:
|
2013-06-13 14:22:42 +00:00
|
|
|
GetLogger().DeleteLogFile();
|
|
|
|
if (_waccess(GetLogger().GetLogFilePath().c_str(), 0) == -1)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
Button_SetCheck(GetControl(Id_LogToFileCheckBox), BST_UNCHECKED);
|
|
|
|
EnableWindow(GetControl(Id_ShowLogFileButton), FALSE);
|
|
|
|
EnableWindow(GetControl(Id_DeleteLogFileButton), FALSE);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_LogToFileCheckBox:
|
2013-06-13 14:22:42 +00:00
|
|
|
if (GetLogger().IsLogToFile())
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2013-06-13 14:22:42 +00:00
|
|
|
GetLogger().StopLogFile();
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-13 14:22:42 +00:00
|
|
|
GetLogger().StartLogFile();
|
|
|
|
if (_waccess(GetLogger().GetLogFilePath().c_str(), 0) != -1)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
2012-12-13 10:11:27 +00:00
|
|
|
EnableWindow(GetControl(Id_ShowLogFileButton), TRUE);
|
|
|
|
EnableWindow(GetControl(Id_DeleteLogFileButton), TRUE);
|
2011-08-28 10:58:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_VerboseLoggingCheckbox:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().SetDebug(!GetRainmeter().GetDebug());
|
2011-08-28 10:58:26 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_EditorEdit:
|
2012-11-12 20:02:01 +00:00
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
{
|
2012-11-13 15:54:32 +00:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
if (GetWindowText((HWND)lParam, buffer, _countof(buffer)) > 0)
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().SetSkinEditor(buffer);
|
2012-11-13 15:54:32 +00:00
|
|
|
}
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_EditorBrowseButton:
|
2012-11-12 20:02:01 +00:00
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
buffer[0] = L'\0';
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
std::wstring editor = GetRainmeter().GetSkinEditor();
|
2012-11-12 20:02:01 +00:00
|
|
|
editor = editor.substr(0, editor.find_last_of(L"/\\")).c_str();
|
|
|
|
|
|
|
|
OPENFILENAME ofn = { sizeof(OPENFILENAME) };
|
|
|
|
ofn.Flags = OFN_FILEMUSTEXIST;
|
|
|
|
ofn.lpstrFilter = L"Executable File (.exe)\0*.exe";
|
|
|
|
ofn.lpstrTitle = L"Select executable file";
|
|
|
|
ofn.lpstrDefExt = L"exe";
|
|
|
|
ofn.lpstrInitialDir = editor.c_str();
|
|
|
|
ofn.nFilterIndex = 0;
|
|
|
|
ofn.lpstrFile = buffer;
|
|
|
|
ofn.nMaxFile = _countof(buffer);
|
|
|
|
ofn.hwndOwner = c_Dialog->GetWindow();
|
|
|
|
|
|
|
|
if (!GetOpenFileName(&ofn))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-12-13 10:11:27 +00:00
|
|
|
Edit_SetText(GetControl(Id_EditorEdit), buffer);
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-12-13 09:12:25 +00:00
|
|
|
case Id_ShowTrayIconCheckBox:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().GetTrayWindow()->SetTrayIcon(!GetRainmeter().GetTrayWindow()->IsTrayIconEnabled());
|
2012-11-12 20:02:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-07-25 22:44:06 +00:00
|
|
|
case Id_UseD2DCheckBox:
|
|
|
|
GetRainmeter().SetUseD2D(!GetRainmeter().GetUseD2D());
|
|
|
|
break;
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
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;
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|