summaryrefslogtreecommitdiff
path: root/plugins/Popup/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
commitbcb27264ba737778e5d3edad36088bacf74f0236 (patch)
treefd1f57744dd380b7babe312a0ab5dc60b48854f2 /plugins/Popup/src
parent940231dc5a484b03a278900e1880aa083472b601 (diff)
- short function names allows to write database loops in one string;
- 'continue' operator can be used then; - multiple bugs fixed in clists; - code becomes much more compact; git-svn-id: http://svn.miranda-ng.org/main/trunk@4403 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Popup/src')
-rw-r--r--plugins/Popup/src/config.cpp37
-rw-r--r--plugins/Popup/src/opt_contacts.cpp111
2 files changed, 47 insertions, 101 deletions
diff --git a/plugins/Popup/src/config.cpp b/plugins/Popup/src/config.cpp
index 811bead19a..c8cca233be 100644
--- a/plugins/Popup/src/config.cpp
+++ b/plugins/Popup/src/config.cpp
@@ -103,18 +103,6 @@ void PopUpPreview()
ppd.cbSize = sizeof(ppd);
ppd.flags = PU2_TCHAR;
-#if defined(_DEBUG)
- // test per-contact popups
- for (HANDLE hContact = db_find_first(); hContact;
- hContact = db_find_next(hContact))
- {
- if (db_get_dw(hContact, "ICQ", "UIN", 0) == 256771455)
- {
- ppd.lchContact = hContact;
- break;
- }
- }
-#endif
ppd.lptzTitle = lptzTitle1Eng;
ppd.lptzText = lptzText1Eng;
ppd.lchIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE);
@@ -128,30 +116,7 @@ void PopUpPreview()
ppd.lptzText = lptzText2;
ppd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
ppd.hbmAvatar = hbmNoAvatar;
-#if defined(_DEBUG)
-//remove testactions
- POPUPACTION actions[3];
- actions[0].cbSize = sizeof(POPUPACTION);
- actions[0].flags = PAF_ENABLED;
- lstrcpyA(actions[0].lpzTitle, "Popup Plus/Test action");
- actions[0].lchIcon = IcoLib_GetIcon(ICO_POPUP_ON,0);
- actions[0].wParam = actions[0].lParam = -1;
-
- actions[1].cbSize = sizeof(POPUPACTION);
- actions[1].flags = PAF_ENABLED;
- lstrcpyA(actions[1].lpzTitle, "Popup Plus/Second test action");
- actions[1].lchIcon = IcoLib_GetIcon(ICO_ACT_CLOSE,0);
- actions[1].wParam = actions[1].lParam = -1;
-
- actions[2].cbSize = sizeof(POPUPACTION);
- actions[2].flags = PAF_ENABLED;
- lstrcpyA(actions[2].lpzTitle, "Popup Plus/One more action");
- actions[2].lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- actions[2].wParam = actions[2].lParam = -1;
-
- ppd.lpActions = actions;
- ppd.actionCount = SIZEOF(actions);
-#endif
+
CallService(MS_POPUP_ADDPOPUP2, (WPARAM)&ppd, APF_NO_HISTORY);
if (PopUpOptions.UseAnimations || PopUpOptions.UseEffect) Sleep((ANIM_TIME*2)/3); //Pause
diff --git a/plugins/Popup/src/opt_contacts.cpp b/plugins/Popup/src/opt_contacts.cpp
index 84e528ea03..b19ee39359 100644
--- a/plugins/Popup/src/opt_contacts.cpp
+++ b/plugins/Popup/src/opt_contacts.cpp
@@ -28,9 +28,8 @@ static void sttSetAllContactIcons(HWND hwndList);
INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
{
TranslateDialogDefault(hwnd);
@@ -40,7 +39,7 @@ INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
SendMessage(GetDlgItem(hwnd, IDC_ICO_BLOCK), STM_SETICON, (WPARAM)IcoLib_GetIcon(ICO_OPT_BLOCK,0), 0);
HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),
- (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK,5,5);
+ (IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK,5,5);
ImageList_AddIcon(hIml, LoadSkinnedIcon(SKINICON_OTHER_SMALLDOT));
ImageList_AddIcon(hIml, IcoLib_GetIcon(ICO_OPT_DEF,0));
ImageList_AddIcon(hIml, IcoLib_GetIcon(ICO_OPT_FAV,0));
@@ -54,75 +53,59 @@ INT_PTR CALLBACK DlgProcContactOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
break;
}
- case WM_NOTIFY:
- {
- switch(((LPNMHDR)lParam)->idFrom)
- {
- case IDC_LIST:
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case IDC_LIST:
+ switch (((LPNMHDR)lParam)->code) {
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ sttSetAllContactIcons(GetDlgItem(hwnd,IDC_LIST));
+ break;
+ case CLN_OPTIONSCHANGED:
+ sttResetListOptions(GetDlgItem(hwnd,IDC_LIST));
+ break;
+ case NM_CLICK:
{
- switch (((LPNMHDR)lParam)->code)
- {
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
- sttSetAllContactIcons(GetDlgItem(hwnd,IDC_LIST));
- break;
- case CLN_OPTIONSCHANGED:
- sttResetListOptions(GetDlgItem(hwnd,IDC_LIST));
- break;
- case NM_CLICK:
- {
- HANDLE hItem;
- NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
- DWORD hitFlags;
- int iImage;
-
- if (nm->iColumn==-1) break;
- hItem=(HANDLE)SendDlgItemMessage(hwnd,IDC_LIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));
- if (hItem==NULL) break;
- if (!(hitFlags&CLCHT_ONITEMEXTRA)) break;
-
- iImage = SendDlgItemMessage(hwnd,IDC_LIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(nm->iColumn,0));
- if (iImage != EMPTY_EXTRA_ICON) {
- for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)
- //hIml element [0] = SKINICON_OTHER_SMALLDOT
- //hIml element [1..5] = IcoLib_GetIcon(....) ~ old sttIcons
+ HANDLE hItem;
+ NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
+ DWORD hitFlags;
+ int iImage;
+
+ if (nm->iColumn==-1) break;
+ hItem=(HANDLE)SendDlgItemMessage(hwnd,IDC_LIST,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));
+ if (hItem==NULL) break;
+ if (!(hitFlags&CLCHT_ONITEMEXTRA)) break;
+
+ iImage = SendDlgItemMessage(hwnd,IDC_LIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(nm->iColumn,0));
+ if (iImage != EMPTY_EXTRA_ICON) {
+ for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)
+ //hIml element [0] = SKINICON_OTHER_SMALLDOT
+ //hIml element [1..5] = IcoLib_GetIcon(....) ~ old sttIcons
SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, (i==nm->iColumn)?i+1:0));
- }
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
- }
}
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
}
+ }
+ break;
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- HWND hwndList = GetDlgItem(hwnd, IDC_LIST);
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
- HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)
- {
- if (SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(i,0)))
- {
- db_set_b(hContact, MODULNAME, "ShowMode", i);
- break;
- }
- }
- }
- return TRUE;
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ HWND hwndList = GetDlgItem(hwnd, IDC_LIST);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i) {
+ if (SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(i,0))) {
+ db_set_b(hContact, MODULNAME, "ShowMode", i);
+ break;
}
}
- break;
}
+ return TRUE;
}
- break;
}
+ break;
}
return FALSE;
@@ -142,9 +125,7 @@ static void sttResetListOptions(HWND hwndList)
static void sttSetAllContactIcons(HWND hwndList)
{
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
DWORD dwMode = db_get_b(hContact, MODULNAME, "ShowMode", 0);
for (int i=0; i < 4 /*SIZEOF(sttIcons)*/; ++i)