summaryrefslogtreecommitdiff
path: root/plugins/HistoryStats/src/dlgoption_subexclude.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/HistoryStats/src/dlgoption_subexclude.cpp')
-rw-r--r--plugins/HistoryStats/src/dlgoption_subexclude.cpp220
1 files changed, 88 insertions, 132 deletions
diff --git a/plugins/HistoryStats/src/dlgoption_subexclude.cpp b/plugins/HistoryStats/src/dlgoption_subexclude.cpp
index 8014a0d00f..e639610717 100644
--- a/plugins/HistoryStats/src/dlgoption_subexclude.cpp
+++ b/plugins/HistoryStats/src/dlgoption_subexclude.cpp
@@ -8,8 +8,8 @@
* DlgOption::SubExclude
*/
-DlgOption::SubExclude::SubExclude()
- : m_hItemAll(NULL), m_bChanged(false)
+DlgOption::SubExclude::SubExclude() :
+ m_hItemAll(NULL), m_bChanged(false)
{
}
@@ -21,107 +21,85 @@ DlgOption::SubExclude::~SubExclude()
BOOL DlgOption::SubExclude::handleMsg(UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_WINDOWPOSCHANGED:
- {
- RECT rClient, rWnd;
-
- GetClientRect(getHWnd(), &rClient);
-
- // clist
- rWnd = utils::getWindowRect(getHWnd(), IDC_CONTACTS);
- rWnd.right = rClient.right;
- rWnd.bottom = rClient.bottom;
- utils::moveWindow(getHWnd(), IDC_CONTACTS, rWnd);
- }
- break;
+ switch (msg) {
+ case WM_WINDOWPOSCHANGED:
+ {
+ RECT rClient, rWnd;
- case WM_NOTIFY:
- {
- NMHDR* p = reinterpret_cast<NMHDR*>(lParam);
+ GetClientRect(getHWnd(), &rClient);
- if (p->idFrom != IDC_CONTACTS)
- {
+ // clist
+ rWnd = utils::getWindowRect(getHWnd(), IDC_CONTACTS);
+ rWnd.right = rClient.right;
+ rWnd.bottom = rClient.bottom;
+ utils::moveWindow(getHWnd(), IDC_CONTACTS, rWnd);
+ }
+ break;
+
+ case WM_NOTIFY:
+ {
+ NMHDR* p = reinterpret_cast<NMHDR*>(lParam);
+ if (p->idFrom != IDC_CONTACTS)
+ break;
+
+ HWND hCList = GetDlgItem(getHWnd(), IDC_CONTACTS);
+
+ switch (p->code) {
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ updateAllContacts(hCList);
+ updateAllGroups(hCList, reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_ROOT, 0)), m_hItemAll);
+ break;
+
+ case CLN_CONTACTMOVED:
+ updateAllGroups(hCList, reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_ROOT, 0)), m_hItemAll);
+ break;
+
+ case CLN_OPTIONSCHANGED:
+ customizeList(hCList);
+ break;
+
+ case NM_CLICK:
+ NMCLISTCONTROL* pNM = reinterpret_cast<NMCLISTCONTROL*>(p);
+ if (pNM->iColumn == -1)
break;
- }
- HWND hCList = GetDlgItem(getHWnd(), IDC_CONTACTS);
-
- switch (p->code)
- {
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
- updateAllContacts(hCList);
- updateAllGroups(hCList, reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_ROOT, 0)), m_hItemAll);
- break;
-
- case CLN_CONTACTMOVED:
- updateAllGroups(hCList, reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_ROOT, 0)), m_hItemAll);
- break;
-
- case CLN_OPTIONSCHANGED:
- customizeList(hCList);
- break;
-
- case NM_CLICK:
- {
- NMCLISTCONTROL* pNM = reinterpret_cast<NMCLISTCONTROL*>(p);
-
- if (pNM->iColumn == -1)
- {
- break;
- }
-
- DWORD dwHitFlags = 0;
- HANDLE hItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_HITTEST, reinterpret_cast<WPARAM>(&dwHitFlags), MAKELPARAM(pNM->pt.x, pNM->pt.y)));
-
- if (!hItem || !(dwHitFlags & CLCHT_ONITEMEXTRA))
- {
- break;
- }
-
- int iImage = SendMessage(hCList, CLM_GETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(pNM->iColumn, 0));
-
- if (iImage != 0xFF)
- {
- iImage = (iImage == 0) ? 1 : 0;
-
- int itemType = SendMessage(hCList, CLM_GETITEMTYPE, reinterpret_cast<WPARAM>(hItem), 0);
-
- if (itemType == CLCIT_CONTACT)
- {
- setAll(hCList, hItem, iImage, false);
- }
- else if (itemType == CLCIT_INFO)
- {
- setAll(hCList, hItem, iImage, true);
- }
- else if (itemType == CLCIT_GROUP)
- {
- if (hItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_CHILD, reinterpret_cast<LPARAM>(hItem))))
- {
- setAll(hCList, hItem, iImage, true);
- }
- }
-
- // update groups
- updateAllGroups(hCList, reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_ROOT, 0)), m_hItemAll);
-
- // mark as dirty
- m_bChanged = true;
- getParent()->settingsChanged();
- }
- }
- break;
+ DWORD dwHitFlags = 0;
+ HANDLE hItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_HITTEST, reinterpret_cast<WPARAM>(&dwHitFlags), MAKELPARAM(pNM->pt.x, pNM->pt.y)));
+ if (!hItem || !(dwHitFlags & CLCHT_ONITEMEXTRA))
+ break;
+
+ int iImage = SendMessage(hCList, CLM_GETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(pNM->iColumn, 0));
+ if (iImage != 0xFF) {
+ iImage = (iImage == 0) ? 1 : 0;
+
+ int itemType = SendMessage(hCList, CLM_GETITEMTYPE, reinterpret_cast<WPARAM>(hItem), 0);
+
+ if (itemType == CLCIT_CONTACT)
+ setAll(hCList, hItem, iImage, false);
+ else if (itemType == CLCIT_INFO)
+ setAll(hCList, hItem, iImage, true);
+ else if (itemType == CLCIT_GROUP) {
+ if (hItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_CHILD, reinterpret_cast<LPARAM>(hItem))))
+ setAll(hCList, hItem, iImage, true);
+ }
+
+ // update groups
+ updateAllGroups(hCList, reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_ROOT, 0)), m_hItemAll);
+
+ // mark as dirty
+ m_bChanged = true;
+ getParent()->settingsChanged();
}
+ break;
}
- break;
+ }
+ break;
- case WM_DESTROY:
- IconLib::unregisterCallback(staticRecreateIcons, reinterpret_cast<LPARAM>(this));
- ImageList_Destroy(reinterpret_cast<HIMAGELIST>(SendDlgItemMessage(getHWnd(), IDC_CONTACTS, CLM_GETEXTRAIMAGELIST, 0, 0)));
- break;
+ case WM_DESTROY:
+ IconLib::unregisterCallback(staticRecreateIcons, reinterpret_cast<LPARAM>(this));
+ ImageList_Destroy(reinterpret_cast<HIMAGELIST>(SendDlgItemMessage(getHWnd(), IDC_CONTACTS, CLM_GETEXTRAIMAGELIST, 0, 0)));
+ break;
}
return FALSE;
@@ -143,10 +121,10 @@ void DlgOption::SubExclude::onWMInitDialog()
SendMessage(hCList, CLM_SETEXTRACOLUMNS, 1, 0);
CLCINFOITEM cii = { 0 };
-
+
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_GROUPFONT;
- cii.pszText = i18n(muT("** All contacts **"));
+ cii.pszText = TranslateT("** All contacts **");
m_hItemAll = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_ADDINFOITEM, 0, reinterpret_cast<LPARAM>(&cii)));
// lock exlucde contacts
@@ -168,7 +146,7 @@ void DlgOption::SubExclude::staticRecreateIcons(LPARAM lParam)
array_each_(i, ExtraIcons)
{
ImageList_AddIcon(hIml, IconLib::getIcon(ExtraIcons[i]));
- }
+ }
}
void DlgOption::SubExclude::loadSettings()
@@ -184,8 +162,7 @@ void DlgOption::SubExclude::loadSettings()
void DlgOption::SubExclude::saveSettings()
{
- if (m_bChanged)
- {
+ if (m_bChanged) {
// update db
HWND hCList = GetDlgItem(getHWnd(), IDC_CONTACTS);
MirandaSettings db;
@@ -202,13 +179,9 @@ void DlgOption::SubExclude::saveSettings()
bool bExcludeOld = db.settingExists(con::SettExclude);
if (bExcludeOld && iImage == 0)
- {
db.delSetting(con::SettExclude);
- }
else if (!bExcludeOld && iImage == 1)
- {
db.writeBool(con::SettExclude, true);
- }
}
hContact = db_find_next(hContact);
@@ -227,10 +200,8 @@ void DlgOption::SubExclude::customizeList(HWND hCList)
SendMessage(hCList, CLM_SETLEFTMARGIN, 2, 0);
SendMessage(hCList, CLM_SETINDENT, 10, 0);
- for(int i = 0; i <= FONTID_MAX; ++i)
- {
+ for (int i = 0; i <= FONTID_MAX; ++i)
SendMessage(hCList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT));
- }
SetWindowLong(hCList, GWL_STYLE, GetWindowLong(hCList, GWL_STYLE) | CLS_SHOWHIDDEN);
}
@@ -246,15 +217,11 @@ void DlgOption::SubExclude::updateAllGroups(HWND hCList, HANDLE hFirstItem, HAND
HANDLE hItem = (typeOfFirst == CLCIT_GROUP) ? hFirstItem : reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, reinterpret_cast<LPARAM>(hFirstItem)));
// MEMO: no short-circuit, otherwise subgroups won't be updated
- while (hItem /* && (bIconOn || !bHasChilds) */)
- {
+ while (hItem /* && (bIconOn || !bHasChilds) */) {
HANDLE hChildItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_CHILD, reinterpret_cast<LPARAM>(hItem)));
-
if (hChildItem)
- {
updateAllGroups(hCList, hChildItem, hItem);
- }
-
+
int iImage = SendMessage(hCList, CLM_GETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(0, 0));
bIconOn = bIconOn && (iImage != 0);
@@ -262,14 +229,13 @@ void DlgOption::SubExclude::updateAllGroups(HWND hCList, HANDLE hFirstItem, HAND
hItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, reinterpret_cast<LPARAM>(hItem)));
}
-
+
// contacts
hItem = (typeOfFirst == CLCIT_CONTACT) ? hFirstItem : reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, reinterpret_cast<LPARAM>(hFirstItem)));
- while (hItem && (bIconOn || !bHasChilds))
- {
+ while (hItem && (bIconOn || !bHasChilds)) {
int iImage = SendMessage(hCList, CLM_GETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(0, 0));
-
+
bIconOn = bIconOn && (iImage != 0);
bHasChilds = bHasChilds || (iImage != 0xFF);
@@ -291,7 +257,7 @@ void DlgOption::SubExclude::updateAllContacts(HWND hCList)
HANDLE hItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_FINDCONTACT, hContact, 0));
if (hItem) {
db.setContact(hContact);
-
+
if (SendMessage(hCList, CLM_GETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(0, 0)) == 0xFF)
SendMessage(hCList, CLM_SETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(0, db.settingExists(con::SettExclude) ? 1 : 0));
}
@@ -304,19 +270,14 @@ void DlgOption::SubExclude::setAll(HWND hCList, HANDLE hFirstItem, int iImage, b
{
int typeOfFirst = SendMessage(hCList, CLM_GETITEMTYPE, reinterpret_cast<WPARAM>(hFirstItem), 0);
- if (bIterate)
- {
+ if (bIterate) {
// check groups
HANDLE hItem = (typeOfFirst == CLCIT_GROUP) ? hFirstItem : reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, reinterpret_cast<LPARAM>(hFirstItem)));
- while (hItem)
- {
+ while (hItem) {
HANDLE hChildItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_CHILD, reinterpret_cast<LPARAM>(hItem)));
-
if (hChildItem)
- {
setAll(hCList, hChildItem, iImage, true);
- }
hItem = reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, reinterpret_cast<LPARAM>(hItem)));
}
@@ -324,15 +285,10 @@ void DlgOption::SubExclude::setAll(HWND hCList, HANDLE hFirstItem, int iImage, b
// check contacts
HANDLE hItem = (typeOfFirst == CLCIT_CONTACT) ? hFirstItem : reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, reinterpret_cast<LPARAM>(hFirstItem)));
-
- while (hItem)
- {
+ while (hItem) {
int iOldIcon = SendMessage(hCList, CLM_GETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(0, 0));
-
if (iOldIcon != 0xFF && iOldIcon != iImage)
- {
SendMessage(hCList, CLM_SETEXTRAIMAGE, reinterpret_cast<WPARAM>(hItem), MAKELPARAM(0, iImage));
- }
hItem = bIterate ? reinterpret_cast<HANDLE>(SendMessage(hCList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, reinterpret_cast<LPARAM>(hItem))) : NULL;
}