- Improved r1034 fix

- Minor tweaks
This commit is contained in:
Birunthan Mohanathas 2011-11-25 19:11:46 +00:00
parent 1ec1809c75
commit b26dafc46f
7 changed files with 78 additions and 62 deletions

View File

@ -57,7 +57,7 @@ CDialog::~CDialog()
** Enables RTL layout.
**
*/
void CDialog::SetRTL()
void CDialog::SetDialogRTL()
{
SetWindowLong(m_Window, GWL_EXSTYLE, GetWindowLong(m_Window, GWL_EXSTYLE) | WS_EX_LAYOUTRTL);
}
@ -91,7 +91,8 @@ BOOL CALLBACK CDialog::SetFontProc(HWND hWnd, LPARAM lParam)
** Constructor.
**
*/
CTab::CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc) : CDialog(CreateDialog(instance, MAKEINTRESOURCE(tabId), owner, tabProc)),
CDialog::CTab::CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc) :
m_Window(CreateDialog(instance, MAKEINTRESOURCE(tabId), owner, tabProc)),
m_Initialized(false)
{
EnableThemeDialogTexture(m_Window, ETDT_ENABLETAB);
@ -103,7 +104,23 @@ CTab::CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc) : CDialo
** Destructor.
**
*/
CTab::~CTab()
CDialog::CTab::~CTab()
{
DestroyWindow(m_Window);
}
/*
** Activate
**
** Activates the tab.
**
*/
void CDialog::CTab::Activate()
{
if (!m_Initialized)
{
Initialize();
}
BringWindowToTop(m_Window);
}

View File

@ -25,11 +25,28 @@ public:
HWND GetWindow() { return m_Window; }
protected:
class CTab
{
public:
HWND GetWindow() { return m_Window; }
bool IsInitialized() { return m_Initialized; }
void Activate();
virtual void Initialize() {}
virtual void Resize(int w, int h) {}
protected:
CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc);
virtual ~CTab();
HWND m_Window;
bool m_Initialized;
};
CDialog(HWND wnd);
virtual ~CDialog();
void SetRTL();
void SetDialogRTL();
void SetDialogFont();
HWND m_Window;
@ -40,19 +57,4 @@ private:
static BOOL CALLBACK SetFontProc(HWND hWnd, LPARAM lParam);
};
class CTab : public CDialog
{
public:
bool IsInitialized() { return m_Initialized; }
virtual void Initialize() {}
virtual void Resize(int w, int h) {}
protected:
CTab(HINSTANCE instance, HWND owner, WORD tabId, DLGPROC tabProc);
virtual ~CTab();
bool m_Initialized;
};
#endif

View File

@ -247,7 +247,7 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
if (wcscmp(GetString(ID_STR_ISRTL), L"1") == 0)
{
// Use RTL layout if using a RTL language
SetRTL();
SetDialogRTL();
}
HWND item = GetDlgItem(m_Window, IDC_ABOUT_TAB);
@ -302,32 +302,22 @@ INT_PTR CDialogAbout::OnNotify(WPARAM wParam, LPARAM lParam)
case IDC_ABOUT_TAB:
if (nm->code == TCN_SELCHANGE)
{
CTab* tab;
int sel = TabCtrl_GetCurSel(nm->hwndFrom);
if (sel == 0)
{
tab = &m_TabLog;
m_TabLog.Activate();
}
else if (sel == 1)
{
tab = &m_TabMeasures;
m_TabMeasures.Activate();
}
else if (sel == 2)
{
tab = &m_TabPlugins;
m_TabPlugins.Activate();
}
else // if (sel == 3)
{
tab = &m_TabVersion;
}
if (tab)
{
if (!tab->IsInitialized())
{
tab->Initialize();
}
BringWindowToTop(tab->GetWindow());
m_TabVersion.Activate();
}
}
break;

View File

@ -229,7 +229,7 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
if (wcscmp(GetString(ID_STR_ISRTL), L"1") == 0)
{
// Use RTL layout if using a RTL language
SetRTL();
SetDialogRTL();
}
HWND item = GetDlgItem(m_Window, IDC_MANAGE_TAB);
@ -306,28 +306,18 @@ INT_PTR CDialogManage::OnNotify(WPARAM wParam, LPARAM lParam)
case IDC_MANAGE_TAB:
if (nm->code == TCN_SELCHANGE)
{
CTab* tab;
int sel = TabCtrl_GetCurSel(nm->hwndFrom);
if (sel == 0)
{
tab = &m_TabSkins;
m_TabSkins.Activate();
}
else if (sel == 1)
{
tab = &m_TabThemes;
m_TabThemes.Activate();
}
else // if (sel == 2)
{
tab = &m_TabSettings;
}
if (tab)
{
if (!tab->IsInitialized())
{
tab->Initialize();
}
BringWindowToTop(tab->GetWindow());
m_TabSettings.Activate();
}
}
break;
@ -477,11 +467,10 @@ void CDialogManage::CTabSkins::Update(CMeterWindow* meterWindow, bool deleted)
HWND item = GetDlgItem(m_Window, IDC_MANAGESKINS_SKINS_TREEVIEW);
TreeView_DeleteAllItems(item);
TV_INSERTSTRUCT tvi = {0};
tvi.hParent = NULL;
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask= TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.item.iImage = tvi.item.iSelectedImage= 0;
TVINSERTSTRUCT tvi = {0};
tvi.hInsertAfter = TVI_FIRST;
tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.item.iImage = tvi.item.iSelectedImage = 0;
PopulateTree(item, tvi, Rainmeter->m_ConfigMenu);
}
}
@ -763,25 +752,24 @@ void CDialogManage::CTabSkins::ReadSkin()
** Populates the treeview with folders and skins.
**
*/
void CDialogManage::CTabSkins::PopulateTree(HWND tree, TV_INSERTSTRUCT& tvi, const std::vector<CRainmeter::CONFIGMENU>& configMenuData)
void CDialogManage::CTabSkins::PopulateTree(HWND tree, TVINSERTSTRUCT& tvi, const std::vector<CRainmeter::CONFIGMENU>& configMenuData)
{
for (int i = 0, isize = (int)configMenuData.size(); i < isize; ++i)
for (int i = (int)configMenuData.size() - 1; i >= 0; --i)
{
const CRainmeter::CONFIGMENU& configMenuS = configMenuData[i];
tvi.item.pszText =(WCHAR*)configMenuS.name.c_str();
if (configMenuS.index == -1)
{
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);
tvi.hParent = (HTREEITEM)TreeView_InsertItem(tree, &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);
TreeView_InsertItem(tree, &tvi);
}
}
}

View File

@ -63,7 +63,7 @@ private:
void DisableControls(bool clear = false);
void ReadSkin();
static void PopulateTree(HWND tree, TV_INSERTSTRUCT& tvi, const std::vector<CRainmeter::CONFIGMENU>& configMenuData);
static void PopulateTree(HWND tree, TVINSERTSTRUCT& tvi, const std::vector<CRainmeter::CONFIGMENU>& configMenuData);
std::wstring m_FileName;
std::wstring m_SkinName;

View File

@ -265,7 +265,24 @@ HICON CTrayWindow::CreateTrayIcon(double value)
}
// Return the default icon if there is no valid measure
return (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
HINSTANCE hExe = GetModuleHandle(NULL);
HINSTANCE hComctl = GetModuleHandle(L"Comctl32");
if (hComctl)
{
// Try LoadIconMetric for better quality with high DPI
FPLOADICONMETRIC loadIconMetric = (FPLOADICONMETRIC)GetProcAddress(hComctl, "LoadIconMetric");
if (loadIconMetric)
{
HICON icon;
HRESULT hr = loadIconMetric(hExe, MAKEINTRESOURCE(IDI_RAINMETER), LIM_SMALL, &icon);
if (SUCCEEDED(hr))
{
return icon;
}
}
}
return (HICON)LoadImage(hExe, MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
}
void CTrayWindow::ReadConfig(CConfigParser& parser)

View File

@ -23,6 +23,8 @@
#include <gdiplus.h>
#include <vector>
typedef HRESULT (WINAPI * FPLOADICONMETRIC)(HINSTANCE hinst, PCWSTR pszName, int lims, HICON* phico);
#define WM_TRAY_DELAYED_REFRESH_ALL WM_APP + 0
#define WM_TRAY_DELAYED_EXECUTE WM_APP + 1