- Minor code refactoring and tweaks

- Minor changes to illustro
This commit is contained in:
Birunthan Mohanathas 2011-11-21 12:53:55 +00:00
parent 347bd7cc9f
commit b11abf09f0
8 changed files with 208 additions and 266 deletions

View File

@ -91,10 +91,10 @@ BOOL CALLBACK CDialog::SetFontProc(HWND hWnd, LPARAM lParam)
** Constructor. ** 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) m_Initialized(false)
{ {
EnableThemeDialogTexture(wnd, ETDT_ENABLETAB); EnableThemeDialogTexture(m_Window, ETDT_ENABLETAB);
} }
/* /*

View File

@ -16,8 +16,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _DIALOG_H_ #ifndef __DIALOG_H__
#define _DIALOG_H_ #define __DIALOG_H__
class CDialog class CDialog
{ {
@ -49,7 +49,7 @@ public:
virtual void Resize(int w, int h) {} virtual void Resize(int w, int h) {}
protected: protected:
CTab(HWND wnd); CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc);
virtual ~CTab(); virtual ~CTab();
bool m_Initialized; bool m_Initialized;

View File

@ -40,10 +40,10 @@ CDialogAbout* CDialogAbout::c_Dialog = NULL;
** **
*/ */
CDialogAbout::CDialogAbout(HWND wnd) : CDialog(wnd), CDialogAbout::CDialogAbout(HWND wnd) : CDialog(wnd),
m_TabLog(), m_TabLog(wnd),
m_TabMeasures(), m_TabMeasures(wnd),
m_TabPlugins(), m_TabPlugins(wnd),
m_TabVersion() m_TabVersion(wnd)
{ {
} }
@ -55,10 +55,6 @@ CDialogAbout::CDialogAbout(HWND wnd) : CDialog(wnd),
*/ */
CDialogAbout::~CDialogAbout() 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) 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() 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; w -= 48;
h -= 100; h -= 100;
c_Dialog->m_TabLog->Resize(w, h); c_Dialog->m_TabLog.Resize(w, h);
c_Dialog->m_TabMeasures->Resize(w, h); c_Dialog->m_TabMeasures.Resize(w, h);
c_Dialog->m_TabPlugins->Resize(w, h); c_Dialog->m_TabPlugins.Resize(w, h);
c_Dialog->m_TabVersion->Resize(w, h); c_Dialog->m_TabVersion.Resize(w, h);
} }
} }
return TRUE; return TRUE;
@ -266,12 +262,6 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
tci.pszText = GetString(ID_STR_VERSION); tci.pszText = GetString(ID_STR_VERSION);
TabCtrl_InsertItem(item, 3, &tci); 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) if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
{ {
// Use UI font (Segoe UI) on 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); int sel = TabCtrl_GetCurSel(nm->hwndFrom);
if (sel == 0) if (sel == 0)
{ {
tab = m_TabLog; tab = &m_TabLog;
} }
else if (sel == 1) else if (sel == 1)
{ {
tab = m_TabMeasures; tab = &m_TabMeasures;
} }
else if (sel == 2) else if (sel == 2)
{ {
tab = m_TabPlugins; tab = &m_TabPlugins;
} }
else // if (sel == 3) else // if (sel == 3)
{ {
tab = m_TabVersion; tab = &m_TabVersion;
} }
if (tab) if (tab)
@ -361,7 +351,7 @@ INT_PTR CDialogAbout::OnNotify(WPARAM wParam, LPARAM lParam)
** Constructor. ** 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_Error(true),
m_Warning(true), m_Warning(true),
m_Notice(true), m_Notice(true),
@ -540,7 +530,7 @@ INT_PTR CALLBACK CDialogAbout::CTabLog::DlgProc(HWND hWnd, UINT uMsg, WPARAM wPa
switch (uMsg) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
return c_Dialog->m_TabLog->OnCommand(wParam, lParam); return c_Dialog->m_TabLog.OnCommand(wParam, lParam);
} }
return FALSE; return FALSE;
@ -597,7 +587,8 @@ INT_PTR CDialogAbout::CTabLog::OnCommand(WPARAM wParam, LPARAM lParam)
** Constructor. ** 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); lvc.pszText = GetString(ID_STR_VALUE);
ListView_InsertColumn(item, 2, &lvc); ListView_InsertColumn(item, 2, &lvc);
// Add entries for each config UpdateSkinList();
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);
} }
/* /*
@ -685,148 +657,128 @@ void CDialogAbout::CTabMeasures::Resize(int w, int h)
*/ */
void CDialogAbout::CTabMeasures::UpdateSkinList() 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 // 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(); const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin(); std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
bool found = false;
for ( ; iter != windows.end(); ++iter) for ( ; iter != windows.end(); ++iter)
{ {
CMeterWindow* meterWindow = (*iter).second; const std::wstring& skinName = (*iter).first;
const std::wstring& skinName = meterWindow->GetSkinName(); std::wstring::size_type curLength = skinName.length();
SendMessage(item, LB_ADDSTRING, NULL, (LPARAM)skinName.c_str()); if (curLength > maxLength)
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); 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; if (windows.empty())
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 (_wcsicmp(selectedItemName, (*iter).first.c_str()) == 0) m_SkinWindow = NULL;
{ item = GetDlgItem(m_Window, IDC_ABOUTMEASURES_ITEMS_LISTVIEW);
SendMessage(item, LB_SETCURSEL, sel, 0); ListView_DeleteAllItems(item);
break; }
} else
++sel; {
// 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. ** 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); if (!meterWindow)
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 (i == selected && // Find selected skin
(entryName == NULL || _wcsicmp(entryName, (*iter).first.c_str()) == 0)) 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); ++iter;
SendMessage(item, WM_SETREDRAW, 0, 0); --selected;
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;
} }
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) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
return c_Dialog->m_TabMeasures->OnCommand(wParam, lParam); return c_Dialog->m_TabMeasures.OnCommand(wParam, lParam);
} }
return FALSE; return FALSE;
@ -876,7 +828,7 @@ INT_PTR CDialogAbout::CTabMeasures::OnCommand(WPARAM wParam, LPARAM lParam)
** Constructor. ** 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. ** 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) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
return c_Dialog->m_TabVersion->OnCommand(wParam, lParam); return c_Dialog->m_TabVersion.OnCommand(wParam, lParam);
case WM_NOTIFY: case WM_NOTIFY:
return c_Dialog->m_TabVersion->OnNotify(wParam, lParam); return c_Dialog->m_TabVersion.OnNotify(wParam, lParam);
} }
return FALSE; return FALSE;

View File

@ -16,8 +16,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _DIALOGABOUT_H_ #ifndef __DIALOGABOUT_H__
#define _DIALOGABOUT_H_ #define __DIALOGABOUT_H__
#include "Dialog.h" #include "Dialog.h"
@ -38,7 +38,7 @@ public:
static void AddLogItem(int level, LPCWSTR time, LPCWSTR message); static void AddLogItem(int level, LPCWSTR time, LPCWSTR message);
static void UpdateSkins(); static void UpdateSkins();
static void UpdateMeasures(LPCTSTR entryName = NULL); static void UpdateMeasures(CMeterWindow* meterWindow);
static WINDOWPLACEMENT c_WindowPlacement; static WINDOWPLACEMENT c_WindowPlacement;
static CDialogAbout* c_Dialog; static CDialogAbout* c_Dialog;
@ -48,7 +48,7 @@ private:
class CTabLog : public CTab class CTabLog : public CTab
{ {
public: public:
CTabLog(HWND window); CTabLog(HWND owner);
virtual void Initialize(); virtual void Initialize();
virtual void Resize(int w, int h); virtual void Resize(int w, int h);
@ -69,7 +69,7 @@ private:
class CTabMeasures : public CTab class CTabMeasures : public CTab
{ {
public: public:
CTabMeasures(HWND window); CTabMeasures(HWND owner);
virtual void Initialize(); virtual void Initialize();
virtual void Resize(int w, int h); virtual void Resize(int w, int h);
@ -78,14 +78,17 @@ private:
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam); INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
void UpdateSkinList(); void UpdateSkinList();
void UpdateMeasureList(LPCTSTR entryName); void UpdateMeasureList(CMeterWindow* meterWindow);
private:
CMeterWindow* m_SkinWindow;
}; };
// Plugins tab // Plugins tab
class CTabPlugins : public CTab class CTabPlugins : public CTab
{ {
public: public:
CTabPlugins(HWND window); CTabPlugins(HWND owner);
virtual void Initialize(); virtual void Initialize();
virtual void Resize(int w, int h); virtual void Resize(int w, int h);
@ -101,7 +104,7 @@ private:
class CTabVersion : public CTab class CTabVersion : public CTab
{ {
public: public:
CTabVersion(HWND window); CTabVersion(HWND owner);
virtual void Initialize(); virtual void Initialize();
virtual void Resize(int w, int h); virtual void Resize(int w, int h);
@ -110,11 +113,11 @@ private:
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam); INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam); INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
}; };
CTabLog* m_TabLog; CTabLog m_TabLog;
CTabMeasures* m_TabMeasures; CTabMeasures m_TabMeasures;
CTabPlugins* m_TabPlugins; CTabPlugins m_TabPlugins;
CTabVersion* m_TabVersion; CTabVersion m_TabVersion;
}; };
#endif #endif

View File

@ -41,9 +41,9 @@ CDialogManage* CDialogManage::c_Dialog = NULL;
** **
*/ */
CDialogManage::CDialogManage(HWND wnd) : CDialog(wnd), CDialogManage::CDialogManage(HWND wnd) : CDialog(wnd),
m_TabSkins(), m_TabSkins(wnd),
m_TabThemes(), m_TabThemes(wnd),
m_TabSettings() m_TabSettings(wnd)
{ {
} }
@ -55,9 +55,6 @@ CDialogManage::CDialogManage(HWND wnd) : CDialog(wnd),
*/ */
CDialogManage::~CDialogManage() CDialogManage::~CDialogManage()
{ {
delete m_TabSkins;
delete m_TabThemes;
delete m_TabSettings;
} }
/* /*
@ -128,13 +125,13 @@ void CDialogManage::OpenSkin(CMeterWindow* meterWindow)
{ {
Open(); Open();
if (c_Dialog && c_Dialog->m_TabSkins) if (c_Dialog)
{ {
std::wstring name = meterWindow->GetSkinName() + L"\\"; std::wstring name = meterWindow->GetSkinName() + L"\\";
name += meterWindow->GetSkinIniFile(); name += meterWindow->GetSkinIniFile();
HWND item = GetDlgItem(c_Dialog->m_TabSkins->GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW); HWND item = GetDlgItem(c_Dialog->m_TabSkins.GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW);
c_Dialog->m_TabSkins->SelectTreeItem(item, TreeView_GetRoot(item), name.c_str()); 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) 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); tci.pszText = GetString(ID_STR_SETTINGS);
TabCtrl_InsertItem(item, 2, &tci); 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) if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
{ {
// Use UI font (Segoe UI) on Vista+ // Use UI font (Segoe UI) on Vista+
SetDialogFont(); SetDialogFont();
// Use arrows instead of plus/minus in the tree for Vista+ // 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); 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); SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0);
if (c_WindowPlacement.length == 0) if (c_WindowPlacement.length == 0)
@ -318,15 +310,15 @@ INT_PTR CDialogManage::OnNotify(WPARAM wParam, LPARAM lParam)
int sel = TabCtrl_GetCurSel(nm->hwndFrom); int sel = TabCtrl_GetCurSel(nm->hwndFrom);
if (sel == 0) if (sel == 0)
{ {
tab = m_TabSkins; tab = &m_TabSkins;
} }
else if (sel == 1) else if (sel == 1)
{ {
tab = m_TabThemes; tab = &m_TabThemes;
} }
else // if (sel == 2) else // if (sel == 2)
{ {
tab = m_TabSettings; tab = &m_TabSettings;
} }
if (tab) if (tab)
@ -359,7 +351,7 @@ INT_PTR CDialogManage::OnNotify(WPARAM wParam, LPARAM lParam)
** Constructor. ** Constructor.
** **
*/ */
CDialogManage::CTabSkins::CTabSkins(HWND wnd) : CTab(wnd), CDialogManage::CTabSkins::CTabSkins(HWND owner) : CTab(Rainmeter->GetResourceInstance(), owner, IDD_MANAGESKINS_DIALOG, DlgProc),
m_SkinWindow(), m_SkinWindow(),
m_HandleCommands(false), m_HandleCommands(false),
m_IgnoreUpdate(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) 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 =(WCHAR*)configMenuS.name.c_str();
tvi.item.iImage = tvi.item.iSelectedImage = 0; HTREEITEM hOldParent = tvi.hParent;
tvi.item.pszText = const_cast<WCHAR*>(configMenuData[i].name.c_str()); tvi.hParent = (HTREEITEM)SendMessage(tree, TVM_INSERTITEM, 0, (LPARAM)&tvi);
HTREEITEM hOldParent = tvi.hParent; PopulateTree(tree, tvi, configMenuS.children);
tvi.hParent = (HTREEITEM)SendMessage(tree, TVM_INSERTITEM, 0, (LPARAM)&tvi); tvi.hParent = hOldParent;
PopulateTree(tree, tvi, configMenuData[i].children); }
tvi.hParent = hOldParent; else
} {
else tvi.item.iImage = tvi.item.iSelectedImage = 1;
{ tvi.item.pszText = (WCHAR*)configMenuS.name.c_str();
tvi.item.iImage = tvi.item.iSelectedImage = 1; SendMessage(tree, TVM_INSERTITEM, 0, (LPARAM)&tvi);
tvi.item.pszText = const_cast<WCHAR*>(configMenuData[i].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.mask = TVIF_TEXT;
tvi.hItem = item; tvi.hItem = item;
tvi.pszText = buffer; tvi.pszText = buffer;
tvi.cchTextMax = MAX_PATH;
std::wstring tmpSz = name; const WCHAR* pos = wcschr(name, L'\\');
std::wstring::size_type pos = tmpSz.find_first_of(L'\\'); if (pos)
if (pos != std::wstring::npos)
{ {
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 // Find and expand the folder
do do
{ {
TreeView_GetItem(tree, &tvi); 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) if ((item = TreeView_GetChild(tree, tvi.hItem)) != NULL)
{ {
TreeView_Expand(tree, tvi.hItem, TVE_EXPAND); TreeView_Expand(tree, tvi.hItem, TVE_EXPAND);
name += tmpSz.length() + 1; ++pos; // Skip the slash
SelectTreeItem(tree, item, name); SelectTreeItem(tree, item, pos);
} }
break; break;
@ -837,6 +826,8 @@ void CDialogManage::CTabSkins::SelectTreeItem(HWND tree, HTREEITEM item, LPCWSTR
} }
else else
{ {
tvi.cchTextMax = MAX_PATH;
// Find and select the file // Find and select the file
do do
{ {
@ -862,10 +853,10 @@ INT_PTR CALLBACK CDialogManage::CTabSkins::DlgProc(HWND hWnd, UINT uMsg, WPARAM
switch (uMsg) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
return c_Dialog->m_TabSkins->OnCommand(wParam, lParam); return c_Dialog->m_TabSkins.OnCommand(wParam, lParam);
case WM_NOTIFY: case WM_NOTIFY:
return c_Dialog->m_TabSkins->OnNotify(wParam, lParam); return c_Dialog->m_TabSkins.OnNotify(wParam, lParam);
} }
return FALSE; return FALSE;
@ -1354,7 +1345,7 @@ INT_PTR CDialogManage::CTabSkins::OnNotify(WPARAM wParam, LPARAM lParam)
** Constructor. ** 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) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
return c_Dialog->m_TabThemes->OnCommand(wParam, lParam); return c_Dialog->m_TabThemes.OnCommand(wParam, lParam);
} }
return FALSE; return FALSE;
@ -1642,7 +1633,7 @@ INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam)
** Constructor. ** 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) switch (uMsg)
{ {
case WM_COMMAND: case WM_COMMAND:
return c_Dialog->m_TabSettings->OnCommand(wParam, lParam); return c_Dialog->m_TabSettings.OnCommand(wParam, lParam);
} }
return FALSE; return FALSE;

View File

@ -16,8 +16,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _DIALOGMANAGE_H_ #ifndef __DIALOGMANAGE_H__
#define _DIALOGMANAGE_H_ #define __DIALOGMANAGE_H__
#include "Dialog.h" #include "Dialog.h"
@ -46,7 +46,7 @@ private:
class CTabSkins : public CTab class CTabSkins : public CTab
{ {
public: public:
CTabSkins(HWND window); CTabSkins(HWND owner);
virtual void Initialize(); virtual void Initialize();
@ -76,7 +76,7 @@ private:
class CTabThemes : public CTab class CTabThemes : public CTab
{ {
public: public:
CTabThemes(HWND window); CTabThemes(HWND owner);
virtual void Initialize(); virtual void Initialize();
@ -89,7 +89,7 @@ private:
class CTabSettings : public CTab class CTabSettings : public CTab
{ {
public: public:
CTabSettings(HWND window); CTabSettings(HWND owner);
virtual void Initialize(); virtual void Initialize();
@ -97,9 +97,9 @@ private:
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam); INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
}; };
CTabSkins* m_TabSkins; CTabSkins m_TabSkins;
CTabThemes* m_TabThemes; CTabThemes m_TabThemes;
CTabSettings* m_TabSettings; CTabSettings m_TabSettings;
}; };
#endif #endif

View File

@ -120,15 +120,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
CMeasure::ReadConfig(parser, section); CMeasure::ReadConfig(parser, section);
const WCHAR* keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER").c_str(); const WCHAR* keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER").c_str();
if (_wcsicmp(keyname, L"HKEY_CLASSES_ROOT") == 0) if (_wcsicmp(keyname, L"HKEY_CURRENT_USER") == 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)
{ {
m_HKey = HKEY_CURRENT_USER; m_HKey = HKEY_CURRENT_USER;
} }
@ -140,6 +132,10 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
{ {
m_HKey = HKEY_CLASSES_ROOT; 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) else if (_wcsicmp(keyname, L"HKEY_PERFORMANCE_DATA") == 0)
{ {
m_HKey = HKEY_PERFORMANCE_DATA; m_HKey = HKEY_PERFORMANCE_DATA;
@ -150,7 +146,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
} }
else else
{ {
std::wstring error = L"HKEY="; std::wstring error = L"RegHKey=";
error += keyname; error += keyname;
error += L" is not valid in ["; error += L" is not valid in [";
error += m_Name; error += m_Name;

View File

@ -723,7 +723,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
case BANG_UPDATE: case BANG_UPDATE:
KillTimer(m_Window, TIMER_METER); // Kill timer temporarily KillTimer(m_Window, TIMER_METER); // Kill timer temporarily
Update(false); Update(false);
CDialogAbout::UpdateMeasures(m_SkinName.c_str()); CDialogAbout::UpdateMeasures(this);
if (m_WindowUpdate >= 0) if (m_WindowUpdate >= 0)
{ {
SetTimer(m_Window, TIMER_METER, m_WindowUpdate, NULL); SetTimer(m_Window, TIMER_METER, m_WindowUpdate, NULL);
@ -798,7 +798,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
case BANG_UPDATEMEASURE: case BANG_UPDATEMEASURE:
UpdateMeasure(arg); UpdateMeasure(arg);
CDialogAbout::UpdateMeasures(m_SkinName.c_str()); CDialogAbout::UpdateMeasures(this);
break; break;
case BANG_DISABLEMEASUREGROUP: case BANG_DISABLEMEASUREGROUP:
@ -815,7 +815,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
case BANG_UPDATEMEASUREGROUP: case BANG_UPDATEMEASUREGROUP:
UpdateMeasure(arg, true); UpdateMeasure(arg, true);
CDialogAbout::UpdateMeasures(m_SkinName.c_str()); CDialogAbout::UpdateMeasures(this);
break; break;
case BANG_SHOW: case BANG_SHOW:
@ -3063,7 +3063,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (wParam == TIMER_METER) if (wParam == TIMER_METER)
{ {
Update(false); Update(false);
CDialogAbout::UpdateMeasures(m_SkinName.c_str()); CDialogAbout::UpdateMeasures(this);
} }
else if (wParam == TIMER_MOUSE) else if (wParam == TIMER_MOUSE)
{ {