summaryrefslogtreecommitdiff
path: root/yapp
diff options
context:
space:
mode:
Diffstat (limited to 'yapp')
-rw-r--r--yapp/common.h2
-rw-r--r--yapp/options.cpp135
-rw-r--r--yapp/popups2.cpp14
-rw-r--r--yapp/popups2.rc23
-rw-r--r--yapp/resource.h10
-rw-r--r--yapp/services.cpp81
-rw-r--r--yapp/services.h9
-rw-r--r--yapp/version.h6
8 files changed, 265 insertions, 15 deletions
diff --git a/yapp/common.h b/yapp/common.h
index d0d05fd..88cff9d 100644
--- a/yapp/common.h
+++ b/yapp/common.h
@@ -37,6 +37,8 @@
#include <stdlib.h>
#include <time.h>
+#define MIRANDA_VER 0x0600
+
#include <newpluginapi.h>
#include <statusmodes.h>
#include <m_database.h>
diff --git a/yapp/options.cpp b/yapp/options.cpp
index ed77921..fa8426d 100644
--- a/yapp/options.cpp
+++ b/yapp/options.cpp
@@ -4,6 +4,7 @@
#include "popwin.h"
#include <commctrl.h>
#include "str_utils.h"
+#include "services.h"
Options options;
@@ -352,27 +353,143 @@ static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
return 0;
}
-int OptInit(WPARAM wParam, LPARAM lParam) {
-#define OPTIONPAGE_OLD_SIZE2 60
+POPUPCLASS *newclasses = 0;
+static BOOL CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ {
+ if(num_classes) {
+ newclasses = (POPUPCLASS *)malloc(num_classes * sizeof(POPUPCLASS));
+ memcpy(newclasses, classes, num_classes * sizeof(POPUPCLASS));
+
+ POPUPCLASS *pc;
+ int index;
+ for(int i = 0; i < num_classes; i++) {
+ pc = &newclasses[i];
+ if(pc->flags & PCF_UNICODE) {
+ index = SendDlgItemMessageW(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pwszDescription);
+ } else {
+ index = SendDlgItemMessageA(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription);
+ }
+ SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_SETITEMDATA, index, i);
+ }
+ }
+ }
+ return FALSE;
+ case WM_COMMAND:
+ if ( LOWORD(wParam) == IDC_LST_CLASSES && HIWORD( wParam ) == LBN_SELCHANGE) {
+ int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_PREVIEW), index != -1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COL_TEXT), index != -1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_COL_BG), index != -1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_TIMEOUT), index != -1);
+ if(index != -1) {
+ int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
+ SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorText);
+ SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorBack);
+ CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, newclasses[i].iSeconds != -1);
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE);
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT));
+ return TRUE;
+ } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
+ if(index != -1) {
+ int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
+ BOOL tr;
+ int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &tr, FALSE);
+ newclasses[i].iSeconds = t;
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ } else {
+ int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
+ if(index != -1) {
+ int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
+ switch(LOWORD(wParam)) {
+ case IDC_CHK_TIMEOUT:
+ {
+ BOOL isChecked = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), isChecked);
+ if(isChecked) newclasses[i].iSeconds = 0;
+ else newclasses[i].iSeconds = -1;
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE);
+ }
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ case IDC_COL_TEXT:
+ newclasses[i].colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0);
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ case IDC_COL_BG:
+ newclasses[i].colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0);
+ SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ break;
+ case IDC_BTN_PREVIEW:
+ if(newclasses[i].flags & PCF_UNICODE) {
+ POPUPCLASS pc = newclasses[i];
+ pc.PluginWindowProc = 0;
+ POPUPDATACLASS d = {sizeof(d), pc.pszName};
+ d.pwszTitle = L"Preview";
+ d.pwszText = L"The quick brown fox jumps over the lazy dog.";
+ CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
+ } else {
+ POPUPCLASS pc = newclasses[i];
+ pc.PluginWindowProc = 0;
+ POPUPDATACLASS d = {sizeof(d), pc.pszName};
+ d.pszTitle = "Preview";
+ d.pszText = "The quick brown fox jumps over the lazy dog.";
+ CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
+ }
+ break;
+ }
+ }
+ }
+ break;
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) {
+ memcpy(classes, newclasses, num_classes * sizeof(POPUPCLASS));
+ char setting[256];
+ for(int i = 0; i < num_classes; i++) {
+ mir_snprintf(setting, 256, "%s/Timeout", classes[i].pszName);
+ DBWriteContactSettingWord(0, MODULE, setting, classes[i].iSeconds);
+ mir_snprintf(setting, 256, "%s/TextCol", classes[i].pszName);
+ DBWriteContactSettingDword(0, MODULE, setting, (DWORD)classes[i].colorText);
+ mir_snprintf(setting, 256, "%s/BgCol", classes[i].pszName);
+ DBWriteContactSettingDword(0, MODULE, setting, (DWORD)classes[i].colorBack);
+ }
+ return TRUE;
+ }
+ break;
+ case WM_DESTROY:
+ if(newclasses) free(newclasses);
+ break;
+ }
+ return 0;
+}
+int OptInit(WPARAM wParam, LPARAM lParam) {
OPTIONSDIALOGPAGE odp = { 0 };
- //odp.cbSize = sizeof(odp);
- odp.cbSize = OPTIONPAGE_OLD_SIZE2;
+ odp.cbSize = sizeof(odp);
odp.flags = ODPF_BOLDGROUPS;
//odp.flags |= ODPF_UNICODE;
odp.position = -790000000;
odp.hInstance = hInst;
+ odp.pszTitle = Translate("PopUps");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1);
- odp.pszTitle = Translate("PopUps");
- //odp.pszTitle = Translate("General");
- //odp.pszGroup = Translate("PopUps");
- //odp.ptszTitle = TranslateT("Updater");
- //odp.ptszGroup = TranslateT("Plugins");
+ odp.pszTab = Translate("Settings");
odp.nIDBottomSimpleControl = 0;
odp.pfnDlgProc = DlgProcOpts1;
CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_CLASSES);
+ odp.pszTab = Translate("Classes");
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOptsClasses;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
return 0;
}
diff --git a/yapp/popups2.cpp b/yapp/popups2.cpp
index cb7f561..56c1c59 100644
--- a/yapp/popups2.cpp
+++ b/yapp/popups2.cpp
@@ -348,6 +348,20 @@ extern "C" int POPUPS2_API Load(PLUGINLINK *link) {
hEventPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ /*
+ // test popup classes
+ POPUPCLASS test = {0};
+ test.cbSize = sizeof(test);
+ test.flags = PCF_TCHAR;
+ test.hIcon = LoadIcon(0, IDI_WARNING);
+ test.colorBack = RGB(0, 0, 0);
+ test.colorText = RGB(255, 255, 255);
+ test.iSeconds = 10;
+ test.ptszDescription = TranslateT("Test popup class");
+ test.pszName = "popup/testclass";
+ CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test);
+ */
+
return 0;
}
diff --git a/yapp/popups2.rc b/yapp/popups2.rc
index f43f15f..2f659c4 100644
--- a/yapp/popups2.rc
+++ b/yapp/popups2.rc
@@ -128,6 +128,21 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
END
+IDD_CLASSES DIALOGEX 0, 0, 294, 223
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LISTBOX IDC_LST_CLASSES,7,18,102,184,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ RTEXT "Text colour:",IDC_STATIC,136,66,80,8
+ RTEXT "Background colour:",IDC_STATIC,136,88,80,8
+ CONTROL "Set timeout",IDC_CHK_TIMEOUT,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,144,122,99,10
+ RTEXT "Timeout value (0 = default):",IDC_STATIC,114,143,121,8
+ EDITTEXT IDC_ED_TIMEOUT,243,140,43,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
+ CONTROL "Custom1",IDC_COL_TEXT,"ColourPicker",WS_DISABLED | WS_TABSTOP,243,61,44,17
+ CONTROL "Custom1",IDC_COL_BG,"ColourPicker",WS_DISABLED | WS_TABSTOP,243,82,44,17
+ PUSHBUTTON "Preview",IDC_BTN_PREVIEW,141,178,130,17,WS_DISABLED
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -152,6 +167,14 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 84
END
+
+ IDD_CLASSES, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 287
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 216
+ END
END
#endif // APSTUDIO_INVOKED
diff --git a/yapp/resource.h b/yapp/resource.h
index 5e3bd9f..d7db4cd 100644
--- a/yapp/resource.h
+++ b/yapp/resource.h
@@ -9,6 +9,7 @@
#define IDI_ICON1 105
#define IDI_POPUP_HISTORY 105
#define IDI_ICON2 106
+#define IDD_CLASSES 107
#define IDC_RAD_NOTIMEOUT 1001
#define IDC_RAD_TIMEOUT 1002
#define IDC_ED_TIMEOUT 1003
@@ -54,20 +55,25 @@
#define IDC_CMB_AV2 1037
#define IDC_CMB_TIME 1038
#define IDC_CUSTOM1 1039
+#define IDC_COL_TEXT 1039
#define IDC_BORDERCOLOUR 1040
+#define IDC_COL_BG 1040
#define IDC_CLOSE 1041
#define IDC_LIST3 1042
#define IDC_LST_HISTORY 1043
#define IDC_HISTORY_FILTER 1044
#define IDC_HISTORY_FILTER_CASESENSITIVE 1046
+#define IDC_LST_CLASSES 1047
+#define IDC_CHK_TIMEOUT 1048
+#define IDC_BUTTON1 1050
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1047
+#define _APS_NEXT_CONTROL_VALUE 1051
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/yapp/services.cpp b/yapp/services.cpp
index 046a104..3708a35 100644
--- a/yapp/services.cpp
+++ b/yapp/services.cpp
@@ -7,7 +7,7 @@
#include <time.h>
#include "str_utils.h"
-#define NUM_SERVICES 13
+#define NUM_SERVICES 16
HANDLE hService[NUM_SERVICES];
HANDLE hMenuShowHistory, hMenuToggleOnOff;
@@ -322,6 +322,76 @@ int PopUp_ShowHistory(WPARAM wParam, LPARAM lParam)
return 0;
}
+int num_classes = 0;
+POPUPCLASS *classes = 0;
+
+int RegisterPopupClass(WPARAM wParam, LPARAM lParam) {
+ POPUPCLASS *pc = (POPUPCLASS *)lParam;
+ pc->pszName = strdup(pc->pszName);
+ if(pc->flags & PCF_UNICODE)
+ pc->pwszDescription = wcsdup(pc->pwszDescription);
+ else
+ pc->pszDescription = strdup(pc->pszDescription);
+
+ char setting[256];
+ mir_snprintf(setting, 256, "%s/Timeout", pc->pszName);
+ pc->iSeconds = DBGetContactSettingWord(0, MODULE, setting, pc->iSeconds);
+ if(pc->iSeconds == (WORD)-1) pc->iSeconds = -1;
+ mir_snprintf(setting, 256, "%s/TextCol", pc->pszName);
+ pc->colorText = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorText);
+ mir_snprintf(setting, 256, "%s/BgCol", pc->pszName);
+ pc->colorBack = (COLORREF)DBGetContactSettingDword(0, MODULE, setting, (DWORD)pc->colorBack);
+
+ classes = (POPUPCLASS *)realloc(classes, sizeof(POPUPCLASS) * (num_classes + 1));
+ memcpy(classes + num_classes, pc, sizeof(POPUPCLASS));
+ num_classes++;
+ return 0;
+}
+
+int CreateClassPopup(WPARAM wParam, LPARAM lParam) {
+ POPUPDATACLASS *pdc = (POPUPDATACLASS *)lParam;
+ POPUPCLASS *pc = 0;
+ if(wParam) pc = (POPUPCLASS *)wParam;
+ else {
+ for(int i = 0; i < num_classes; i++) {
+ if(strcmp(classes[i].pszName, pdc->pszClassName) == 0) {
+ pc = &classes[i];
+ break;
+ }
+ }
+ }
+ if(pc) {
+ if(pc->flags & PCF_UNICODE) {
+ POPUPDATAW pdw = {0};
+ pdw.colorBack = pc->colorBack;
+ pdw.colorText = pc->colorText;
+ pdw.lchIcon = pc->hIcon;
+ pdw.iSeconds = pc->iSeconds;
+ pdw.PluginWindowProc = pc->PluginWindowProc;
+
+ pdw.PluginData = pdc->PluginData;
+ wcsncpy(pdw.lpwzContactName, pdc->pwszTitle, MAX_CONTACTNAME);
+ wcsncpy(pdw.lpwzText, pdc->pwszText, MAX_SECONDLINE);
+
+ CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pdw, 0);
+ } else {
+ POPUPDATAEX pd = {0};
+ pd.colorBack = pc->colorBack;
+ pd.colorText = pc->colorText;
+ pd.lchIcon = pc->hIcon;
+ pd.iSeconds = pc->iSeconds;
+ pd.PluginWindowProc = pc->PluginWindowProc;
+
+ pd.PluginData = pdc->PluginData;
+ strncpy(pd.lpzContactName, pdc->pszTitle, MAX_CONTACTNAME);
+ strncpy(pd.lpzText, pdc->pszText, MAX_SECONDLINE);
+
+ CallService(MS_POPUP_ADDPOPUP, (WPARAM)&pd, 0);
+ }
+ }
+ return 0;
+}
+
int PrebuildMenu(WPARAM wParam, LPARAM lParam) {
return 0;
}
@@ -347,6 +417,9 @@ void InitServices() {
hService[i++] = CreateServiceFunction(MS_POPUP_SHOWHISTORY, PopUp_ShowHistory);
hService[i++] = CreateServiceFunction("PopUp/ToggleEnabled", TogglePopups);
+ hService[i++] = CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass);
+ hService[i++] = CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup);
+
CLISTMENUITEM menu = {0};
menu.cbSize=sizeof(menu);
@@ -374,6 +447,12 @@ void InitServices() {
}
void DeinitServices() {
+ for(int i = 0; i < num_classes; i++) {
+ free(classes[i].pszName);
+ free(classes[i].pszDescription);
+ }
+ free(classes); num_classes = 0;
+
UnhookEvent(hEventBuildMenu);
for(int i = 0; i < NUM_SERVICES; i++)
diff --git a/yapp/services.h b/yapp/services.h
index 35f6285..91761f9 100644
--- a/yapp/services.h
+++ b/yapp/services.h
@@ -1,6 +1,8 @@
#ifndef _SERVICES_INC
#define _SERVICES_INC
+#include <m_popup.h>
+
void InitServices();
void DeinitServices();
@@ -20,6 +22,13 @@ int ShowMessage(WPARAM wParam, LPARAM lParam);
int PopUp_ShowHistory(WPARAM wParam, LPARAM lParam);
int TogglePopups(WPARAM wParam, LPARAM lParam);
+
+int RegisterPopupClass(WPARAM wParam, LPARAM lParam);
+int CreateClassPopup(WPARAM wParam, LPARAM lParam);
*/
+extern int num_classes;
+extern POPUPCLASS *classes;
+
+
#endif
diff --git a/yapp/version.h b/yapp/version.h
index 4531f90..43c5156 100644
--- a/yapp/version.h
+++ b/yapp/version.h
@@ -2,9 +2,9 @@
#define __VERSION_H_INCLUDED
#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 3
-#define __RELEASE_NUM 1
-#define __BUILD_NUM 3
+#define __MINOR_VERSION 4
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM