diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-10 20:23:50 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-10 20:23:50 +0000 |
commit | 84bb8836befd3d31b22562bb02f4ecf22e92c4a9 (patch) | |
tree | 0bc3561fc6b2a79fac4d5dea115deeaafcb1faef /plugins/AVS/src/options.cpp | |
parent | 568b27ff1197231b26d097dc05bcbb27ddd53efa (diff) |
avatars related code cleaning & reordering
git-svn-id: http://svn.miranda-ng.org/main/trunk@5638 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AVS/src/options.cpp')
-rw-r--r-- | plugins/AVS/src/options.cpp | 86 |
1 files changed, 72 insertions, 14 deletions
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 3120f43d60..8e7556629d 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -37,9 +37,7 @@ extern HICON g_hIcon; extern int CreateAvatarInCache(HANDLE hContact, struct avatarCacheEntry *ace, char *szProto);
extern INT_PTR ProtectAvatar(WPARAM wParam, LPARAM lParam);
-extern int SetAvatarAttribute(HANDLE hContact, DWORD attrib, int mode);
extern int ChangeAvatar(HANDLE hContact, BOOL fLoad, BOOL fNotifyHist = FALSE, int pa_format = 0);
-extern void DeleteAvatarFromCache(HANDLE, BOOL);
extern HBITMAP LoadPNG(struct avatarCacheEntry *ace, char *szFilename);
extern HANDLE GetContactThatHaveTheAvatar(HANDLE hContact, int locked = -1);
@@ -188,7 +186,7 @@ static void SetProtoPic(char *szProto) static char* g_selectedProto;
-INT_PTR CALLBACK DlgProcOptionsAvatars(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcOptionsAvatars(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
@@ -253,7 +251,9 @@ INT_PTR CALLBACK DlgProcOptionsAvatars(HWND hwndDlg, UINT msg, WPARAM wParam, LP return FALSE;
}
-INT_PTR CALLBACK DlgProcOptionsOwn(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static INT_PTR CALLBACK DlgProcOptionsOwn(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
@@ -289,11 +289,11 @@ static char* GetProtoFromList(HWND hwndDlg, int iItem) if ( !ListView_GetItem( GetDlgItem(hwndDlg, IDC_PROTOCOLS), &item ))
return NULL;
- protoPicCacheEntry* pce = ( protoPicCacheEntry* )item.lParam;
+ protoPicCacheEntry *pce = ( protoPicCacheEntry* )item.lParam;
return ( pce == NULL ) ? NULL : pce->szProtoname;
}
-INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_PROTOCOLS);
HWND hwndChoosePic = GetDlgItem(hwndDlg, IDC_SETPROTOPIC);
@@ -419,9 +419,9 @@ INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPA }
}
break;
+
case 0:
- switch (((LPNMHDR) lParam)->code) {
- case PSN_APPLY:
+ if (((LPNMHDR) lParam)->code == PSN_APPLY) {
for (int i = 0; i < ListView_GetItemCount(hwndList); i++) {
char *szProto = GetProtoFromList(hwndDlg, i);
@@ -444,7 +444,9 @@ INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPA return FALSE;
}
-void LoadTransparentData(HWND hwndDlg, HANDLE hContact)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static void LoadTransparentData(HWND hwndDlg, HANDLE hContact)
{
CheckDlgButton(hwndDlg, IDC_MAKETRANSPBKG, db_get_b(hContact, "ContactPhoto", "MakeTransparentBkg", db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0)));
SendDlgItemMessage(hwndDlg, IDC_BKG_NUM_POINTS_SPIN, UDM_SETPOS, 0, (LPARAM)db_get_w(hContact, "ContactPhoto", "TranspBkgNumPoints", db_get_w(0, AVS_MODULE, "TranspBkgNumPoints", 5)));
@@ -459,7 +461,7 @@ void LoadTransparentData(HWND hwndDlg, HANDLE hContact) EnableWindow(GetDlgItem(hwndDlg, IDC_BKG_COLOR_DIFFERENCE), transp_enabled);
}
-void SaveTransparentData(HWND hwndDlg, HANDLE hContact)
+static void SaveTransparentData(HWND hwndDlg, HANDLE hContact)
{
BOOL transp = IsDlgButtonChecked(hwndDlg, IDC_MAKETRANSPBKG);
if (db_get_b(0, AVS_MODULE, "MakeTransparentBkg", 0) == transp)
@@ -480,7 +482,7 @@ void SaveTransparentData(HWND hwndDlg, HANDLE hContact) db_set_w(hContact, "ContactPhoto", "TranspBkgColorDiff", tmp);
}
-void SaveTransparentData(HWND hwndDlg, HANDLE hContact, BOOL locked)
+static void SaveTransparentData(HWND hwndDlg, HANDLE hContact, BOOL locked)
{
SaveTransparentData(hwndDlg, hContact);
@@ -734,7 +736,34 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA return FALSE;
}
-INT_PTR CALLBACK DlgProcAvatarUserInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+int OptInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.hInstance = g_hInst;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pszGroup = LPGEN("Contacts");
+ odp.pszTitle = LPGEN("Avatars");
+
+ odp.pszTab = LPGEN("Protocols");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_PICTS);
+ odp.pfnDlgProc = DlgProcOptionsProtos;
+ Options_AddPage(wParam, &odp);
+
+ odp.pszTab = LPGEN("Contact Avatars");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_AVATARS);
+ odp.pfnDlgProc = DlgProcOptionsAvatars;
+ Options_AddPage(wParam, &odp);
+
+ odp.pszTab = LPGEN("Own Avatars");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_OWN);
+ odp.pfnDlgProc = DlgProcOptionsOwn;
+ Options_AddPage(wParam, &odp);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static INT_PTR CALLBACK DlgProcAvatarUserInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HANDLE hContact;
struct WindowData *dat = (struct WindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
@@ -889,7 +918,9 @@ INT_PTR CALLBACK DlgProcAvatarUserInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LP return FALSE;
}
-static char * GetSelectedProtocol(HWND hwndDlg)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static char* GetSelectedProtocol(HWND hwndDlg)
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_PROTOCOLS);
@@ -1005,7 +1036,7 @@ static void EnableDisableProtocols(HWND hwndDlg, BOOL init) }
}
-INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_INITDIALOG:
@@ -1131,3 +1162,30 @@ INT_PTR CALLBACK DlgProcAvatarProtoInfo(HWND hwndDlg, UINT msg, WPARAM wParam, L }
return FALSE;
}
+
+int OnDetailsInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.hIcon = g_hIcon;
+ odp.hInstance = g_hInst;
+ odp.pszTitle = LPGEN("Avatar");
+
+ HANDLE hContact = (HANDLE)lParam;
+ if (hContact == NULL) {
+ // User dialog
+ odp.pfnDlgProc = DlgProcAvatarProtoInfo;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_PROTO_AVATARS);
+ UserInfo_AddPage(wParam, &odp);
+ }
+ else {
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL || db_get_b(NULL, AVS_MODULE, szProto, 1)) {
+ // Contact dialog
+ odp.pfnDlgProc = DlgProcAvatarUserInfo;
+ odp.position = -2000000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_USER_AVATAR);
+ UserInfo_AddPage(wParam, &odp);
+ }
+ }
+ return 0;
+}
|