mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Minor code refactoring and tweaks
- Minor changes to illustro
This commit is contained in:
parent
347bd7cc9f
commit
b11abf09f0
@ -91,10 +91,10 @@ BOOL CALLBACK CDialog::SetFontProc(HWND hWnd, LPARAM lParam)
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CTab::CTab(HWND wnd) : CDialog(wnd),
|
||||
CTab::CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc) : CDialog(CreateDialog(instance, MAKEINTRESOURCE(tabId), owner, tabProc)),
|
||||
m_Initialized(false)
|
||||
{
|
||||
EnableThemeDialogTexture(wnd, ETDT_ENABLETAB);
|
||||
EnableThemeDialogTexture(m_Window, ETDT_ENABLETAB);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DIALOG_H_
|
||||
#define _DIALOG_H_
|
||||
#ifndef __DIALOG_H__
|
||||
#define __DIALOG_H__
|
||||
|
||||
class CDialog
|
||||
{
|
||||
@ -49,7 +49,7 @@ public:
|
||||
virtual void Resize(int w, int h) {}
|
||||
|
||||
protected:
|
||||
CTab(HWND wnd);
|
||||
CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc);
|
||||
virtual ~CTab();
|
||||
|
||||
bool m_Initialized;
|
||||
|
@ -40,10 +40,10 @@ CDialogAbout* CDialogAbout::c_Dialog = NULL;
|
||||
**
|
||||
*/
|
||||
CDialogAbout::CDialogAbout(HWND wnd) : CDialog(wnd),
|
||||
m_TabLog(),
|
||||
m_TabMeasures(),
|
||||
m_TabPlugins(),
|
||||
m_TabVersion()
|
||||
m_TabLog(wnd),
|
||||
m_TabMeasures(wnd),
|
||||
m_TabPlugins(wnd),
|
||||
m_TabVersion(wnd)
|
||||
{
|
||||
}
|
||||
|
||||
@ -55,10 +55,6 @@ CDialogAbout::CDialogAbout(HWND wnd) : CDialog(wnd),
|
||||
*/
|
||||
CDialogAbout::~CDialogAbout()
|
||||
{
|
||||
delete m_TabLog;
|
||||
delete m_TabMeasures;
|
||||
delete m_TabPlugins;
|
||||
delete m_TabVersion;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -139,25 +135,25 @@ void CDialogAbout::ShowAboutLog()
|
||||
|
||||
void CDialogAbout::AddLogItem(int level, LPCWSTR time, LPCWSTR message)
|
||||
{
|
||||
if (c_Dialog && c_Dialog->m_TabLog && c_Dialog->m_TabLog->IsInitialized())
|
||||
if (c_Dialog && c_Dialog->m_TabLog.IsInitialized())
|
||||
{
|
||||
c_Dialog->m_TabLog->AddItem(level, time, message);
|
||||
c_Dialog->m_TabLog.AddItem(level, time, message);
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogAbout::UpdateSkins()
|
||||
{
|
||||
if (c_Dialog && c_Dialog->m_TabMeasures && c_Dialog->m_TabMeasures->IsInitialized())
|
||||
if (c_Dialog && c_Dialog->m_TabMeasures.IsInitialized())
|
||||
{
|
||||
c_Dialog->m_TabMeasures->UpdateSkinList();
|
||||
c_Dialog->m_TabMeasures.UpdateSkinList();
|
||||
}
|
||||
}
|
||||
|
||||
void CDialogAbout::UpdateMeasures(LPCTSTR entryName)
|
||||
void CDialogAbout::UpdateMeasures(CMeterWindow* meterWindow)
|
||||
{
|
||||
if (c_Dialog && c_Dialog->m_TabMeasures && c_Dialog->m_TabMeasures->IsInitialized())
|
||||
if (c_Dialog && c_Dialog->m_TabMeasures.IsInitialized())
|
||||
{
|
||||
c_Dialog->m_TabMeasures->UpdateMeasureList(entryName);
|
||||
c_Dialog->m_TabMeasures.UpdateMeasureList(meterWindow);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,10 +208,10 @@ INT_PTR CALLBACK CDialogAbout::DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
||||
|
||||
w -= 48;
|
||||
h -= 100;
|
||||
c_Dialog->m_TabLog->Resize(w, h);
|
||||
c_Dialog->m_TabMeasures->Resize(w, h);
|
||||
c_Dialog->m_TabPlugins->Resize(w, h);
|
||||
c_Dialog->m_TabVersion->Resize(w, h);
|
||||
c_Dialog->m_TabLog.Resize(w, h);
|
||||
c_Dialog->m_TabMeasures.Resize(w, h);
|
||||
c_Dialog->m_TabPlugins.Resize(w, h);
|
||||
c_Dialog->m_TabVersion.Resize(w, h);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -266,12 +262,6 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
|
||||
tci.pszText = GetString(ID_STR_VERSION);
|
||||
TabCtrl_InsertItem(item, 3, &tci);
|
||||
|
||||
HINSTANCE instance = Rainmeter->GetResourceInstance();
|
||||
m_TabLog = new CTabLog(CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUTLOG_DIALOG), m_Window, CTabLog::DlgProc));
|
||||
m_TabMeasures = new CTabMeasures(CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUTMEASURES_DIALOG), m_Window, CTabMeasures::DlgProc));
|
||||
m_TabPlugins = new CTabPlugins(CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUTPLUGINS_DIALOG), m_Window, CTabPlugins::DlgProc));
|
||||
m_TabVersion = new CTabVersion(CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUTVERSION_DIALOG), m_Window, CTabVersion::DlgProc));
|
||||
|
||||
if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
|
||||
{
|
||||
// Use UI font (Segoe UI) on Vista+
|
||||
@ -316,19 +306,19 @@ INT_PTR CDialogAbout::OnNotify(WPARAM wParam, LPARAM lParam)
|
||||
int sel = TabCtrl_GetCurSel(nm->hwndFrom);
|
||||
if (sel == 0)
|
||||
{
|
||||
tab = m_TabLog;
|
||||
tab = &m_TabLog;
|
||||
}
|
||||
else if (sel == 1)
|
||||
{
|
||||
tab = m_TabMeasures;
|
||||
tab = &m_TabMeasures;
|
||||
}
|
||||
else if (sel == 2)
|
||||
{
|
||||
tab = m_TabPlugins;
|
||||
tab = &m_TabPlugins;
|
||||
}
|
||||
else // if (sel == 3)
|
||||
{
|
||||
tab = m_TabVersion;
|
||||
tab = &m_TabVersion;
|
||||
}
|
||||
|
||||
if (tab)
|
||||
@ -361,7 +351,7 @@ INT_PTR CDialogAbout::OnNotify(WPARAM wParam, LPARAM lParam)
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogAbout::CTabLog::CTabLog(HWND wnd) : CTab(wnd),
|
||||
CDialogAbout::CTabLog::CTabLog(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_ABOUTLOG_DIALOG, DlgProc),
|
||||
m_Error(true),
|
||||
m_Warning(true),
|
||||
m_Notice(true),
|
||||
@ -540,7 +530,7 @@ INT_PTR CALLBACK CDialogAbout::CTabLog::DlgProc(HWND hWnd, UINT uMsg, WPARAM wPa
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
return c_Dialog->m_TabLog->OnCommand(wParam, lParam);
|
||||
return c_Dialog->m_TabLog.OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -597,7 +587,8 @@ INT_PTR CDialogAbout::CTabLog::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogAbout::CTabMeasures::CTabMeasures(HWND wnd) : CTab(wnd)
|
||||
CDialogAbout::CTabMeasures::CTabMeasures(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_ABOUTMEASURES_DIALOG, DlgProc),
|
||||
m_SkinWindow()
|
||||
{
|
||||
}
|
||||
|
||||
@ -631,26 +622,7 @@ void CDialogAbout::CTabMeasures::Initialize()
|
||||
lvc.pszText = GetString(ID_STR_VALUE);
|
||||
ListView_InsertColumn(item, 2, &lvc);
|
||||
|
||||
// Add entries for each config
|
||||
item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTBOX);
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
const std::wstring& skinName = meterWindow->GetSkinName();
|
||||
SendMessage(item, LB_ADDSTRING, NULL, (LPARAM)skinName.c_str());
|
||||
size_t namelength = skinName.length();
|
||||
|
||||
int currwidth = (int)SendMessage(item, LB_GETHORIZONTALEXTENT, NULL, NULL);
|
||||
if (6 * (int)namelength > currwidth)
|
||||
{
|
||||
SendMessage(item, LB_SETHORIZONTALEXTENT, 6 * namelength, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// Select first item
|
||||
SendMessage(item, LB_SETCURSEL, 0, 0);
|
||||
UpdateSkinList();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -685,148 +657,128 @@ void CDialogAbout::CTabMeasures::Resize(int w, int h)
|
||||
*/
|
||||
void CDialogAbout::CTabMeasures::UpdateSkinList()
|
||||
{
|
||||
WCHAR* selectedItemName = NULL;
|
||||
|
||||
HWND item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTBOX);
|
||||
int selected = (int)SendMessage(item, LB_GETCURSEL, 0, 0);
|
||||
|
||||
// Get current selected entry
|
||||
if (selected != LB_ERR)
|
||||
{
|
||||
int selectedItemLen = (int)SendMessage(item, LB_GETTEXTLEN, selected, 0);
|
||||
|
||||
if (selectedItemLen != LB_ERR)
|
||||
{
|
||||
selectedItemName = new WCHAR[selectedItemLen + 1];
|
||||
|
||||
if (LB_ERR != SendMessage(item, LB_GETTEXT, selected, (LPARAM)selectedItemName))
|
||||
{
|
||||
selectedItemName[selectedItemLen] = L'\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
delete [] selectedItemName;
|
||||
selectedItemName = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete all entries
|
||||
SendMessage(item, LB_RESETCONTENT, 0, 0);
|
||||
HWND item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTBOX);
|
||||
ListBox_ResetContent(item);
|
||||
|
||||
// TODO Move following to common
|
||||
// Add entries for each skin
|
||||
std::wstring::size_type maxLength = 0;
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
bool found = false;
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
const std::wstring& skinName = meterWindow->GetSkinName();
|
||||
SendMessage(item, LB_ADDSTRING, NULL, (LPARAM)skinName.c_str());
|
||||
size_t namelength = skinName.length();
|
||||
|
||||
int currwidth = (int)SendMessage(item, LB_GETHORIZONTALEXTENT, NULL, NULL);
|
||||
if (6 * (int)namelength > currwidth)
|
||||
const std::wstring& skinName = (*iter).first;
|
||||
std::wstring::size_type curLength = skinName.length();
|
||||
if (curLength > maxLength)
|
||||
{
|
||||
SendMessage(item, LB_SETHORIZONTALEXTENT, 6 * namelength, NULL);
|
||||
maxLength = curLength;
|
||||
}
|
||||
|
||||
const WCHAR* name = skinName.c_str();
|
||||
int index = ListBox_AddString(item, name);
|
||||
if (!found && m_SkinWindow == (*iter).second)
|
||||
{
|
||||
found = true;
|
||||
m_SkinWindow = (*iter).second;
|
||||
ListBox_SetCurSel(item, index);
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedItemName != NULL)
|
||||
ListBox_SetHorizontalExtent(item, 6 * maxLength);
|
||||
|
||||
if (!found)
|
||||
{
|
||||
int sel = 0;
|
||||
SendMessage(item, LB_SETCURSEL, sel, 0);
|
||||
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
if (windows.empty())
|
||||
{
|
||||
if (_wcsicmp(selectedItemName, (*iter).first.c_str()) == 0)
|
||||
{
|
||||
SendMessage(item, LB_SETCURSEL, sel, 0);
|
||||
break;
|
||||
}
|
||||
++sel;
|
||||
m_SkinWindow = NULL;
|
||||
item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTVIEW);
|
||||
ListView_DeleteAllItems(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default to first skin
|
||||
m_SkinWindow = (*windows.begin()).second;
|
||||
ListBox_SetCurSel(item, 0);
|
||||
UpdateMeasureList(m_SkinWindow);
|
||||
}
|
||||
|
||||
delete [] selectedItemName;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** UpdateSkinList
|
||||
** UpdateMeasureList
|
||||
**
|
||||
** Updates the list of measures and values.
|
||||
**
|
||||
*/
|
||||
void CDialogAbout::CTabMeasures::UpdateMeasureList(LPCTSTR entryName)
|
||||
void CDialogAbout::CTabMeasures::UpdateMeasureList(CMeterWindow* meterWindow)
|
||||
{
|
||||
HWND item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTBOX);
|
||||
int selected = (int)SendMessage(item, LB_GETCURSEL, NULL, NULL);
|
||||
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for (int i = 0; iter != windows.end(); ++i, ++iter)
|
||||
if (!meterWindow)
|
||||
{
|
||||
if (i == selected &&
|
||||
(entryName == NULL || _wcsicmp(entryName, (*iter).first.c_str()) == 0))
|
||||
// Find selected skin
|
||||
HWND item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTBOX);
|
||||
int selected = (int)SendMessage(item, LB_GETCURSEL, NULL, NULL);
|
||||
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
while (selected && iter != windows.end())
|
||||
{
|
||||
item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTVIEW);
|
||||
SendMessage(item, WM_SETREDRAW, 0, 0);
|
||||
int count = ListView_GetItemCount(item);
|
||||
int index = 0;
|
||||
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
const std::list<CMeasure*>& measures = meterWindow->GetMeasures();
|
||||
std::list<CMeasure*>::const_iterator j = measures.begin();
|
||||
for ( ; j != measures.end(); ++j)
|
||||
{
|
||||
const WCHAR* name = (*j)->GetName();
|
||||
std::wstring val = (*j)->GetStats();
|
||||
|
||||
WCHAR buffer[256];
|
||||
double minVal = (*j)->GetMinValue();
|
||||
double maxVal = (*j)->GetMaxValue();
|
||||
CMeasure::GetScaledValue(AUTOSCALE_ON, 1, minVal, buffer, _countof(buffer));
|
||||
std::wstring range = buffer;
|
||||
range += L" - ";
|
||||
CMeasure::GetScaledValue(AUTOSCALE_ON, 1, maxVal, buffer, _countof(buffer));
|
||||
range += buffer;
|
||||
|
||||
if (name && *name)
|
||||
{
|
||||
if (index < count)
|
||||
{
|
||||
ListView_SetItemText(item, index, 0, (WCHAR*)name);
|
||||
}
|
||||
else
|
||||
{
|
||||
LVITEM vitem;
|
||||
vitem.mask = LVIF_TEXT;
|
||||
vitem.iItem = index;
|
||||
vitem.iSubItem = 0;
|
||||
vitem.pszText = (WCHAR*)name;
|
||||
ListView_InsertItem(item, &vitem);
|
||||
}
|
||||
|
||||
ListView_SetItemText(item, index, 1, (WCHAR*)range.c_str());
|
||||
ListView_SetItemText(item, index, 2, (WCHAR*)val.c_str());
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > index)
|
||||
{
|
||||
// Delete unnecessary items
|
||||
for (int j = index; j < count; ++j)
|
||||
{
|
||||
ListView_DeleteItem(item, index);
|
||||
}
|
||||
}
|
||||
|
||||
SendMessage(item, WM_SETREDRAW, 1, 0);
|
||||
break;
|
||||
++iter;
|
||||
--selected;
|
||||
}
|
||||
|
||||
m_SkinWindow = (*iter).second;
|
||||
}
|
||||
else if (meterWindow != m_SkinWindow)
|
||||
{
|
||||
// Called by a skin other than currently visible one, so return
|
||||
return;
|
||||
}
|
||||
|
||||
HWND item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTVIEW);
|
||||
SendMessage(item, WM_SETREDRAW, FALSE, 0);
|
||||
int count = ListView_GetItemCount(item);
|
||||
int index = 0;
|
||||
|
||||
const std::list<CMeasure*>& measures = m_SkinWindow->GetMeasures();
|
||||
std::list<CMeasure*>::const_iterator j = measures.begin();
|
||||
for ( ; j != measures.end(); ++j)
|
||||
{
|
||||
const WCHAR* name = (*j)->GetName();;
|
||||
if (index < count)
|
||||
{
|
||||
ListView_SetItemText(item, index, 0, (WCHAR*)name);
|
||||
}
|
||||
else
|
||||
{
|
||||
LVITEM vitem;
|
||||
vitem.mask = LVIF_TEXT;
|
||||
vitem.iItem = index;
|
||||
vitem.iSubItem = 0;
|
||||
vitem.pszText = (WCHAR*)name;
|
||||
ListView_InsertItem(item, &vitem);
|
||||
}
|
||||
|
||||
WCHAR buffer[256];
|
||||
CMeasure::GetScaledValue(AUTOSCALE_ON, 1, (*j)->GetMinValue(), buffer, _countof(buffer));
|
||||
std::wstring range = buffer;
|
||||
range += L" - ";
|
||||
CMeasure::GetScaledValue(AUTOSCALE_ON, 1, (*j)->GetMaxValue(), buffer, _countof(buffer));
|
||||
range += buffer;
|
||||
|
||||
ListView_SetItemText(item, index, 1, (WCHAR*)range.c_str());
|
||||
ListView_SetItemText(item, index, 2, (WCHAR*)(*j)->GetStats());
|
||||
++index;
|
||||
}
|
||||
|
||||
// Delete unnecessary items
|
||||
while (count > index)
|
||||
{
|
||||
ListView_DeleteItem(item, index);
|
||||
--count;
|
||||
}
|
||||
|
||||
SendMessage(item, WM_SETREDRAW, TRUE, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -840,7 +792,7 @@ INT_PTR CALLBACK CDialogAbout::CTabMeasures::DlgProc(HWND hWnd, UINT uMsg, WPARA
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
return c_Dialog->m_TabMeasures->OnCommand(wParam, lParam);
|
||||
return c_Dialog->m_TabMeasures.OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -876,7 +828,7 @@ INT_PTR CDialogAbout::CTabMeasures::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogAbout::CTabPlugins::CTabPlugins(HWND wnd) : CTab(wnd)
|
||||
CDialogAbout::CTabPlugins::CTabPlugins(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_ABOUTPLUGINS_DIALOG, DlgProc)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1012,7 +964,7 @@ INT_PTR CALLBACK CDialogAbout::CTabPlugins::DlgProc(HWND hWnd, UINT uMsg, WPARAM
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogAbout::CTabVersion::CTabVersion(HWND wnd) : CTab(wnd)
|
||||
CDialogAbout::CTabVersion::CTabVersion(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_ABOUTMEASURES_DIALOG, DlgProc)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1070,10 +1022,10 @@ INT_PTR CALLBACK CDialogAbout::CTabVersion::DlgProc(HWND hWnd, UINT uMsg, WPARAM
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
return c_Dialog->m_TabVersion->OnCommand(wParam, lParam);
|
||||
return c_Dialog->m_TabVersion.OnCommand(wParam, lParam);
|
||||
|
||||
case WM_NOTIFY:
|
||||
return c_Dialog->m_TabVersion->OnNotify(wParam, lParam);
|
||||
return c_Dialog->m_TabVersion.OnNotify(wParam, lParam);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DIALOGABOUT_H_
|
||||
#define _DIALOGABOUT_H_
|
||||
#ifndef __DIALOGABOUT_H__
|
||||
#define __DIALOGABOUT_H__
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
@ -38,7 +38,7 @@ public:
|
||||
|
||||
static void AddLogItem(int level, LPCWSTR time, LPCWSTR message);
|
||||
static void UpdateSkins();
|
||||
static void UpdateMeasures(LPCTSTR entryName = NULL);
|
||||
static void UpdateMeasures(CMeterWindow* meterWindow);
|
||||
|
||||
static WINDOWPLACEMENT c_WindowPlacement;
|
||||
static CDialogAbout* c_Dialog;
|
||||
@ -48,7 +48,7 @@ private:
|
||||
class CTabLog : public CTab
|
||||
{
|
||||
public:
|
||||
CTabLog(HWND window);
|
||||
CTabLog(HWND owner);
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void Resize(int w, int h);
|
||||
@ -69,7 +69,7 @@ private:
|
||||
class CTabMeasures : public CTab
|
||||
{
|
||||
public:
|
||||
CTabMeasures(HWND window);
|
||||
CTabMeasures(HWND owner);
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void Resize(int w, int h);
|
||||
@ -78,14 +78,17 @@ private:
|
||||
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
void UpdateSkinList();
|
||||
void UpdateMeasureList(LPCTSTR entryName);
|
||||
void UpdateMeasureList(CMeterWindow* meterWindow);
|
||||
|
||||
private:
|
||||
CMeterWindow* m_SkinWindow;
|
||||
};
|
||||
|
||||
// Plugins tab
|
||||
class CTabPlugins : public CTab
|
||||
{
|
||||
public:
|
||||
CTabPlugins(HWND window);
|
||||
CTabPlugins(HWND owner);
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void Resize(int w, int h);
|
||||
@ -101,7 +104,7 @@ private:
|
||||
class CTabVersion : public CTab
|
||||
{
|
||||
public:
|
||||
CTabVersion(HWND window);
|
||||
CTabVersion(HWND owner);
|
||||
|
||||
virtual void Initialize();
|
||||
virtual void Resize(int w, int h);
|
||||
@ -111,10 +114,10 @@ private:
|
||||
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
||||
CTabLog* m_TabLog;
|
||||
CTabMeasures* m_TabMeasures;
|
||||
CTabPlugins* m_TabPlugins;
|
||||
CTabVersion* m_TabVersion;
|
||||
CTabLog m_TabLog;
|
||||
CTabMeasures m_TabMeasures;
|
||||
CTabPlugins m_TabPlugins;
|
||||
CTabVersion m_TabVersion;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -41,9 +41,9 @@ CDialogManage* CDialogManage::c_Dialog = NULL;
|
||||
**
|
||||
*/
|
||||
CDialogManage::CDialogManage(HWND wnd) : CDialog(wnd),
|
||||
m_TabSkins(),
|
||||
m_TabThemes(),
|
||||
m_TabSettings()
|
||||
m_TabSkins(wnd),
|
||||
m_TabThemes(wnd),
|
||||
m_TabSettings(wnd)
|
||||
{
|
||||
}
|
||||
|
||||
@ -55,9 +55,6 @@ CDialogManage::CDialogManage(HWND wnd) : CDialog(wnd),
|
||||
*/
|
||||
CDialogManage::~CDialogManage()
|
||||
{
|
||||
delete m_TabSkins;
|
||||
delete m_TabThemes;
|
||||
delete m_TabSettings;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -128,13 +125,13 @@ void CDialogManage::OpenSkin(CMeterWindow* meterWindow)
|
||||
{
|
||||
Open();
|
||||
|
||||
if (c_Dialog && c_Dialog->m_TabSkins)
|
||||
if (c_Dialog)
|
||||
{
|
||||
std::wstring name = meterWindow->GetSkinName() + L"\\";
|
||||
name += meterWindow->GetSkinIniFile();
|
||||
|
||||
HWND item = GetDlgItem(c_Dialog->m_TabSkins->GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW);
|
||||
c_Dialog->m_TabSkins->SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
|
||||
HWND item = GetDlgItem(c_Dialog->m_TabSkins.GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW);
|
||||
c_Dialog->m_TabSkins.SelectTreeItem(item, TreeView_GetRoot(item), name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,9 +143,9 @@ void CDialogManage::OpenSkin(CMeterWindow* meterWindow)
|
||||
*/
|
||||
void CDialogManage::UpdateSkins(CMeterWindow* meterWindow, bool deleted)
|
||||
{
|
||||
if (c_Dialog && c_Dialog->m_TabSkins && c_Dialog->m_TabSkins->IsInitialized())
|
||||
if (c_Dialog && c_Dialog->m_TabSkins.IsInitialized())
|
||||
{
|
||||
c_Dialog->m_TabSkins->Update(meterWindow, deleted);
|
||||
c_Dialog->m_TabSkins.Update(meterWindow, deleted);
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,22 +242,17 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
|
||||
tci.pszText = GetString(ID_STR_SETTINGS);
|
||||
TabCtrl_InsertItem(item, 2, &tci);
|
||||
|
||||
HINSTANCE instance = Rainmeter->GetResourceInstance();
|
||||
m_TabSkins = new CTabSkins(CreateDialog(instance, MAKEINTRESOURCE(IDD_MANAGESKINS_DIALOG), m_Window, CTabSkins::DlgProc));
|
||||
m_TabThemes = new CTabThemes(CreateDialog(instance, MAKEINTRESOURCE(IDD_MANAGETHEMES_DIALOG), m_Window, CTabThemes::DlgProc));
|
||||
m_TabSettings = new CTabSettings(CreateDialog(instance, MAKEINTRESOURCE(IDD_MANAGESETTINGS_DIALOG), m_Window, CTabSettings::DlgProc));
|
||||
|
||||
if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
|
||||
{
|
||||
// Use UI font (Segoe UI) on Vista+
|
||||
SetDialogFont();
|
||||
|
||||
// Use arrows instead of plus/minus in the tree for Vista+
|
||||
item = GetDlgItem(m_TabSkins->GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW);
|
||||
item = GetDlgItem(m_TabSkins.GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW);
|
||||
SetWindowTheme(item, L"explorer", NULL);
|
||||
}
|
||||
|
||||
item = GetDlgItem(m_TabSkins->GetWindow(), IDC_MANAGESKINS_FILE_TEXT);
|
||||
item = GetDlgItem(m_TabSkins.GetWindow(), IDC_MANAGESKINS_FILE_TEXT);
|
||||
SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0);
|
||||
|
||||
if (c_WindowPlacement.length == 0)
|
||||
@ -318,15 +310,15 @@ INT_PTR CDialogManage::OnNotify(WPARAM wParam, LPARAM lParam)
|
||||
int sel = TabCtrl_GetCurSel(nm->hwndFrom);
|
||||
if (sel == 0)
|
||||
{
|
||||
tab = m_TabSkins;
|
||||
tab = &m_TabSkins;
|
||||
}
|
||||
else if (sel == 1)
|
||||
{
|
||||
tab = m_TabThemes;
|
||||
tab = &m_TabThemes;
|
||||
}
|
||||
else // if (sel == 2)
|
||||
{
|
||||
tab = m_TabSettings;
|
||||
tab = &m_TabSettings;
|
||||
}
|
||||
|
||||
if (tab)
|
||||
@ -359,7 +351,7 @@ INT_PTR CDialogManage::OnNotify(WPARAM wParam, LPARAM lParam)
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogManage::CTabSkins::CTabSkins(HWND wnd) : CTab(wnd),
|
||||
CDialogManage::CTabSkins::CTabSkins(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_MANAGESKINS_DIALOG, DlgProc),
|
||||
m_SkinWindow(),
|
||||
m_HandleCommands(false),
|
||||
m_IgnoreUpdate(false)
|
||||
@ -773,25 +765,23 @@ void CDialogManage::CTabSkins::ReadSkin()
|
||||
*/
|
||||
void CDialogManage::CTabSkins::PopulateTree(HWND tree, TV_INSERTSTRUCT& tvi, const std::vector<CRainmeter::CONFIGMENU>& configMenuData)
|
||||
{
|
||||
if (!configMenuData.empty())
|
||||
for (int i = 0, isize = (int)configMenuData.size(); i < isize; ++i)
|
||||
{
|
||||
for (int i = 0, isize = (int)configMenuData.size(); i < isize; ++i)
|
||||
const CRainmeter::CONFIGMENU& configMenuS = configMenuData[i];
|
||||
if (configMenuS.index == -1)
|
||||
{
|
||||
if (configMenuData[i].index == -1)
|
||||
{
|
||||
tvi.item.iImage = tvi.item.iSelectedImage = 0;
|
||||
tvi.item.pszText = const_cast<WCHAR*>(configMenuData[i].name.c_str());
|
||||
HTREEITEM hOldParent = tvi.hParent;
|
||||
tvi.hParent = (HTREEITEM)SendMessage(tree, TVM_INSERTITEM, 0, (LPARAM)&tvi);
|
||||
PopulateTree(tree, tvi, configMenuData[i].children);
|
||||
tvi.hParent = hOldParent;
|
||||
}
|
||||
else
|
||||
{
|
||||
tvi.item.iImage = tvi.item.iSelectedImage = 1;
|
||||
tvi.item.pszText = const_cast<WCHAR*>(configMenuData[i].name.c_str());
|
||||
SendMessage(tree, TVM_INSERTITEM, 0, (LPARAM)&tvi);
|
||||
}
|
||||
tvi.item.iImage = tvi.item.iSelectedImage = 0;
|
||||
tvi.item.pszText =(WCHAR*)configMenuS.name.c_str();
|
||||
HTREEITEM hOldParent = tvi.hParent;
|
||||
tvi.hParent = (HTREEITEM)SendMessage(tree, TVM_INSERTITEM, 0, (LPARAM)&tvi);
|
||||
PopulateTree(tree, tvi, configMenuS.children);
|
||||
tvi.hParent = hOldParent;
|
||||
}
|
||||
else
|
||||
{
|
||||
tvi.item.iImage = tvi.item.iSelectedImage = 1;
|
||||
tvi.item.pszText = (WCHAR*)configMenuS.name.c_str();
|
||||
SendMessage(tree, TVM_INSERTITEM, 0, (LPARAM)&tvi);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -809,25 +799,24 @@ void CDialogManage::CTabSkins::SelectTreeItem(HWND tree, HTREEITEM item, LPCWSTR
|
||||
tvi.mask = TVIF_TEXT;
|
||||
tvi.hItem = item;
|
||||
tvi.pszText = buffer;
|
||||
tvi.cchTextMax = MAX_PATH;
|
||||
|
||||
std::wstring tmpSz = name;
|
||||
std::wstring::size_type pos = tmpSz.find_first_of(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
const WCHAR* pos = wcschr(name, L'\\');
|
||||
if (pos)
|
||||
{
|
||||
tmpSz.resize(pos);
|
||||
const int folderLen = pos - name;
|
||||
tvi.cchTextMax = folderLen + 1; // Length of folder name plus 1 for NULL
|
||||
|
||||
// Find and expand the folder
|
||||
do
|
||||
{
|
||||
TreeView_GetItem(tree, &tvi);
|
||||
if (wcscmp(buffer, tmpSz.c_str()) == 0)
|
||||
if (wcsncmp(buffer, name, folderLen) == 0)
|
||||
{
|
||||
if ((item = TreeView_GetChild(tree, tvi.hItem)) != NULL)
|
||||
{
|
||||
TreeView_Expand(tree, tvi.hItem, TVE_EXPAND);
|
||||
name += tmpSz.length() + 1;
|
||||
SelectTreeItem(tree, item, name);
|
||||
++pos; // Skip the slash
|
||||
SelectTreeItem(tree, item, pos);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -837,6 +826,8 @@ void CDialogManage::CTabSkins::SelectTreeItem(HWND tree, HTREEITEM item, LPCWSTR
|
||||
}
|
||||
else
|
||||
{
|
||||
tvi.cchTextMax = MAX_PATH;
|
||||
|
||||
// Find and select the file
|
||||
do
|
||||
{
|
||||
@ -862,10 +853,10 @@ INT_PTR CALLBACK CDialogManage::CTabSkins::DlgProc(HWND hWnd, UINT uMsg, WPARAM
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
return c_Dialog->m_TabSkins->OnCommand(wParam, lParam);
|
||||
return c_Dialog->m_TabSkins.OnCommand(wParam, lParam);
|
||||
|
||||
case WM_NOTIFY:
|
||||
return c_Dialog->m_TabSkins->OnNotify(wParam, lParam);
|
||||
return c_Dialog->m_TabSkins.OnNotify(wParam, lParam);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -1354,7 +1345,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogManage::CTabThemes::CTabThemes(HWND wnd) : CTab(wnd)
|
||||
CDialogManage::CTabThemes::CTabThemes(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_MANAGETHEMES_DIALOG, DlgProc)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1387,7 +1378,7 @@ INT_PTR CALLBACK CDialogManage::CTabThemes::DlgProc(HWND hWnd, UINT uMsg, WPARAM
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
return c_Dialog->m_TabThemes->OnCommand(wParam, lParam);
|
||||
return c_Dialog->m_TabThemes.OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -1642,7 +1633,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
** Constructor.
|
||||
**
|
||||
*/
|
||||
CDialogManage::CTabSettings::CTabSettings(HWND wnd) : CTab(wnd)
|
||||
CDialogManage::CTabSettings::CTabSettings(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_MANAGESETTINGS_DIALOG, DlgProc)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1719,7 +1710,7 @@ INT_PTR CALLBACK CDialogManage::CTabSettings::DlgProc(HWND hWnd, UINT uMsg, WPAR
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
return c_Dialog->m_TabSettings->OnCommand(wParam, lParam);
|
||||
return c_Dialog->m_TabSettings.OnCommand(wParam, lParam);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -16,8 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DIALOGMANAGE_H_
|
||||
#define _DIALOGMANAGE_H_
|
||||
#ifndef __DIALOGMANAGE_H__
|
||||
#define __DIALOGMANAGE_H__
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
@ -46,7 +46,7 @@ private:
|
||||
class CTabSkins : public CTab
|
||||
{
|
||||
public:
|
||||
CTabSkins(HWND window);
|
||||
CTabSkins(HWND owner);
|
||||
|
||||
virtual void Initialize();
|
||||
|
||||
@ -76,7 +76,7 @@ private:
|
||||
class CTabThemes : public CTab
|
||||
{
|
||||
public:
|
||||
CTabThemes(HWND window);
|
||||
CTabThemes(HWND owner);
|
||||
|
||||
virtual void Initialize();
|
||||
|
||||
@ -89,7 +89,7 @@ private:
|
||||
class CTabSettings : public CTab
|
||||
{
|
||||
public:
|
||||
CTabSettings(HWND window);
|
||||
CTabSettings(HWND owner);
|
||||
|
||||
virtual void Initialize();
|
||||
|
||||
@ -97,9 +97,9 @@ private:
|
||||
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
||||
CTabSkins* m_TabSkins;
|
||||
CTabThemes* m_TabThemes;
|
||||
CTabSettings* m_TabSettings;
|
||||
CTabSkins m_TabSkins;
|
||||
CTabThemes m_TabThemes;
|
||||
CTabSettings m_TabSettings;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -120,15 +120,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
const WCHAR* keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER").c_str();
|
||||
if (_wcsicmp(keyname, L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if (_wcsicmp(keyname, L"HKEY_CURRENT_CONFIG") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_CONFIG;
|
||||
}
|
||||
else if (_wcsicmp(keyname, L"HKEY_CURRENT_USER") == 0)
|
||||
if (_wcsicmp(keyname, L"HKEY_CURRENT_USER") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_USER;
|
||||
}
|
||||
@ -140,6 +132,10 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if (_wcsicmp(keyname, L"HKEY_CURRENT_CONFIG") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_CONFIG;
|
||||
}
|
||||
else if (_wcsicmp(keyname, L"HKEY_PERFORMANCE_DATA") == 0)
|
||||
{
|
||||
m_HKey = HKEY_PERFORMANCE_DATA;
|
||||
@ -150,7 +146,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"HKEY=";
|
||||
std::wstring error = L"RegHKey=";
|
||||
error += keyname;
|
||||
error += L" is not valid in [";
|
||||
error += m_Name;
|
||||
|
@ -723,7 +723,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
case BANG_UPDATE:
|
||||
KillTimer(m_Window, TIMER_METER); // Kill timer temporarily
|
||||
Update(false);
|
||||
CDialogAbout::UpdateMeasures(m_SkinName.c_str());
|
||||
CDialogAbout::UpdateMeasures(this);
|
||||
if (m_WindowUpdate >= 0)
|
||||
{
|
||||
SetTimer(m_Window, TIMER_METER, m_WindowUpdate, NULL);
|
||||
@ -798,7 +798,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
|
||||
case BANG_UPDATEMEASURE:
|
||||
UpdateMeasure(arg);
|
||||
CDialogAbout::UpdateMeasures(m_SkinName.c_str());
|
||||
CDialogAbout::UpdateMeasures(this);
|
||||
break;
|
||||
|
||||
case BANG_DISABLEMEASUREGROUP:
|
||||
@ -815,7 +815,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
|
||||
case BANG_UPDATEMEASUREGROUP:
|
||||
UpdateMeasure(arg, true);
|
||||
CDialogAbout::UpdateMeasures(m_SkinName.c_str());
|
||||
CDialogAbout::UpdateMeasures(this);
|
||||
break;
|
||||
|
||||
case BANG_SHOW:
|
||||
@ -3063,7 +3063,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
if (wParam == TIMER_METER)
|
||||
{
|
||||
Update(false);
|
||||
CDialogAbout::UpdateMeasures(m_SkinName.c_str());
|
||||
CDialogAbout::UpdateMeasures(this);
|
||||
}
|
||||
else if (wParam == TIMER_MOUSE)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user