summaryrefslogtreecommitdiff
path: root/tipper/options.cpp
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2006-11-01 14:46:09 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2006-11-01 14:46:09 +0000
commita13e82647294da4add976a24335fec50d7bfe905 (patch)
tree087acc8d5085391fe71cde7299269c4d0f583c30 /tipper/options.cpp
parentbded3f3d452e097995cbb1e695aaec13a739d1af (diff)
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@15 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'tipper/options.cpp')
-rw-r--r--tipper/options.cpp1126
1 files changed, 1126 insertions, 0 deletions
diff --git a/tipper/options.cpp b/tipper/options.cpp
new file mode 100644
index 0000000..260ccbb
--- /dev/null
+++ b/tipper/options.cpp
@@ -0,0 +1,1126 @@
+#include "common.h"
+#include "options.h"
+#include "resource.h"
+#include "popwin.h"
+#include <commctrl.h>
+
+Options options;
+
+#define WMU_ENABLE_LIST_BUTTONS (WM_USER + 0x030)
+#define WMU_ENABLE_MODULE_ENTRY (WM_USER + 0x031)
+
+void CreateDefaultItems() {
+ DSListNode *ds_node;
+ DIListNode *di_node;
+
+ // last message item
+ di_node = (DIListNode *)malloc(sizeof(DIListNode));
+ _tcsncpy(di_node->di.label, _T("Last message: (%sys:last_msg_reltime% ago)"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%sys:last_msg%"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = true;
+ di_node->next = options.di_list;
+ options.di_list = di_node;
+ options.di_count++;
+
+ // status message item
+ di_node = (DIListNode *)malloc(sizeof(DIListNode));
+ _tcsncpy(di_node->di.label, _T("Status message:"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%sys:status_msg%"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = true;
+ di_node->next = options.di_list;
+ options.di_list = di_node;
+ options.di_count++;
+
+ // status substitution
+ ds_node = (DSListNode *)malloc(sizeof(DSListNode));
+ _tcsncpy(ds_node->ds.name, _T("status"), LABEL_LEN);
+ ds_node->ds.type = DVT_PROTODB;
+ strncpy(ds_node->ds.setting_name, "Status", SETTING_NAME_LEN);
+ ds_node->ds.translate_func_id = 1;
+ ds_node->next = options.ds_list;
+ options.ds_list = ds_node;
+ options.ds_count++;
+
+ // status item
+ di_node = (DIListNode *)malloc(sizeof(DIListNode));
+ _tcsncpy(di_node->di.label, _T("Status:"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%status%"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = false;
+ di_node->next = options.di_list;
+ options.di_list = di_node;
+ options.di_count++;
+
+ // client substitution
+ ds_node = (DSListNode *)malloc(sizeof(DSListNode));
+ _tcsncpy(ds_node->ds.name, _T("client"), LABEL_LEN);
+ ds_node->ds.type = DVT_PROTODB;
+ strncpy(ds_node->ds.setting_name, "MirVer", SETTING_NAME_LEN);
+ ds_node->ds.translate_func_id = 0;
+ ds_node->next = options.ds_list;
+ options.ds_list = ds_node;
+ options.ds_count++;
+
+ // client item
+ di_node = (DIListNode *)malloc(sizeof(DIListNode));
+ _tcsncpy(di_node->di.label, _T("Client:"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%client%"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = false;
+ di_node->next = options.di_list;
+ options.di_list = di_node;
+ options.di_count++;
+
+ // idle time substitution (long date)
+ ds_node = (DSListNode *)malloc(sizeof(DSListNode));
+ _tcsncpy(ds_node->ds.name, _T("idle"), LABEL_LEN);
+ ds_node->ds.type = DVT_PROTODB;
+ strncpy(ds_node->ds.setting_name, "IdleTS", SETTING_NAME_LEN);
+ ds_node->ds.translate_func_id = 15;
+ ds_node->next = options.ds_list;
+ options.ds_list = ds_node;
+ options.ds_count++;
+
+ // idle time substitution (time difference)
+ ds_node = (DSListNode *)malloc(sizeof(DSListNode));
+ _tcsncpy(ds_node->ds.name, _T("idle_diff"), LABEL_LEN);
+ ds_node->ds.type = DVT_PROTODB;
+ strncpy(ds_node->ds.setting_name, "IdleTS", SETTING_NAME_LEN);
+ ds_node->ds.translate_func_id = 3;
+ ds_node->next = options.ds_list;
+ options.ds_list = ds_node;
+ options.ds_count++;
+
+
+ // idle item
+ di_node = (DIListNode *)malloc(sizeof(DIListNode));
+ _tcsncpy(di_node->di.label, _T("Idle:"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%idle% (%idle_diff% ago)"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = false;
+ di_node->next = options.di_list;
+ options.di_list = di_node;
+ options.di_count++;
+
+ // first name substitution
+ ds_node = (DSListNode *)malloc(sizeof(DSListNode));
+ _tcsncpy(ds_node->ds.name, _T("first_name"), LABEL_LEN);
+ ds_node->ds.type = DVT_PROTODB;
+ strncpy(ds_node->ds.setting_name, "FirstName", SETTING_NAME_LEN);
+ ds_node->ds.translate_func_id = 0;
+ ds_node->next = options.ds_list;
+ options.ds_list = ds_node;
+ options.ds_count++;
+
+ // last name substitution
+ ds_node = (DSListNode *)malloc(sizeof(DSListNode));
+ _tcsncpy(ds_node->ds.name, _T("last_name"), LABEL_LEN);
+ ds_node->ds.type = DVT_PROTODB;
+ strncpy(ds_node->ds.setting_name, "LastName", SETTING_NAME_LEN);
+ ds_node->ds.translate_func_id = 0;
+ ds_node->next = options.ds_list;
+ options.ds_list = ds_node;
+ options.ds_count++;
+
+ // name item
+ di_node = (DIListNode *)malloc(sizeof(DIListNode));
+ _tcsncpy(di_node->di.label, _T("Name:"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%first_name% %last_name%"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = false;
+ di_node->next = options.di_list;
+ options.di_list = di_node;
+ options.di_count++;
+
+}
+
+bool LoadDS(DisplaySubst *ds, int index) {
+ char setting[512];
+ DBVARIANT dbv;
+ mir_snprintf(setting, 512, "Name%d", index);
+ ds->name[0] = 0;
+ if(!DBGetContactSettingWString(0, MODULE, setting, &dbv)) {
+ _tcsncpy(ds->name, dbv.pwszVal, LABEL_LEN);
+ DBFreeVariant(&dbv);
+ } else if(!DBGetContactSettingStringUtf(0, MODULE, setting, &dbv)) {
+ MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, ds->name, LABEL_LEN);
+ DBFreeVariant(&dbv);
+ } else if(!DBGetContactSetting(0, MODULE, setting, &dbv)) {
+ if(dbv.type == DBVT_ASCIIZ) MultiByteToWideChar(code_page, 0, dbv.pszVal, -1, ds->name, LABEL_LEN);
+ DBFreeVariant(&dbv);
+ } else
+ return false;
+ ds->name[LABEL_LEN - 1] = 0;
+
+ mir_snprintf(setting, 512, "Type%d", index);
+ ds->type = (DisplaySubstType)DBGetContactSettingByte(0, MODULE, setting, DVT_PROTODB);
+
+ mir_snprintf(setting, 512, "Module%d", index);
+ ds->module_name[0] = 0;
+ if(!DBGetContactSetting(0, MODULE, setting, &dbv)) {
+ strncpy(ds->module_name, dbv.pszVal, MODULE_NAME_LEN);
+ ds->module_name[MODULE_NAME_LEN - 1] = 0;
+ DBFreeVariant(&dbv);
+ }
+
+ mir_snprintf(setting, 512, "Setting%d", index);
+ ds->setting_name[0] = 0;
+ if(!DBGetContactSetting(0, MODULE, setting, &dbv)) {
+ strncpy(ds->setting_name, dbv.pszVal, SETTING_NAME_LEN);
+ ds->setting_name[SETTING_NAME_LEN - 1] = 0;
+ DBFreeVariant(&dbv);
+ }
+
+ mir_snprintf(setting, 512, "TransFuncId%d", index);
+ ds->translate_func_id = DBGetContactSettingDword(0, MODULE, setting, (DWORD)-1);
+
+ // a little backward compatibility
+ if((DWORD)ds->translate_func_id == (DWORD)-1) {
+ mir_snprintf(setting, 512, "TransFunc%d", index);
+ ds->translate_func_id = (DWORD)DBGetContactSettingWord(0, MODULE, setting, 0);
+ }
+ return true;
+}
+
+void SaveDS(DisplaySubst *ds, int index) {
+ char setting[512];
+ mir_snprintf(setting, 512, "Name%d", index);
+ if(DBWriteContactSettingWString(0, MODULE, setting, ds->name)) {
+ char buff[LABEL_LEN];
+ WideCharToMultiByte(code_page, 0, ds->name, -1, buff, LABEL_LEN, 0, 0);
+ buff[LABEL_LEN] = 0;
+ DBWriteContactSettingString(0, MODULE, setting, buff);
+ }
+ mir_snprintf(setting, 512, "Type%d", index);
+ DBWriteContactSettingByte(0, MODULE, setting, (BYTE)ds->type);
+ mir_snprintf(setting, 512, "Module%d", index);
+ DBWriteContactSettingString(0, MODULE, setting, ds->module_name);
+ mir_snprintf(setting, 512, "Setting%d", index);
+ DBWriteContactSettingString(0, MODULE, setting, ds->setting_name);
+ mir_snprintf(setting, 512, "TransFuncId%d", index);
+ DBWriteContactSettingDword(0, MODULE, setting, (WORD)ds->translate_func_id);
+}
+
+bool LoadDI(DisplayItem *di, int index) {
+ char setting[512];
+ DBVARIANT dbv;
+ mir_snprintf(setting, 512, "DILabel%d", index);
+ di->label[0] = 0;
+ if(!DBGetContactSettingWString(0, MODULE, setting, &dbv)) {
+ _tcsncpy(di->label, dbv.pwszVal, LABEL_LEN);
+ DBFreeVariant(&dbv);
+ } else if(!DBGetContactSettingStringUtf(0, MODULE, setting, &dbv)) {
+ MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, di->label, LABEL_LEN);
+ DBFreeVariant(&dbv);
+ } else if(!DBGetContactSetting(0, MODULE, setting, &dbv)) {
+ if(dbv.type == DBVT_ASCIIZ) MultiByteToWideChar(code_page, 0, dbv.pszVal, -1, di->label, LABEL_LEN);
+ DBFreeVariant(&dbv);
+ } else
+ return false;
+ di->label[LABEL_LEN - 1] = 0;
+
+ mir_snprintf(setting, 512, "DIValue%d", index);
+ di->value[0] = 0;
+ if(!DBGetContactSettingWString(0, MODULE, setting, &dbv)) {
+ _tcsncpy(di->value, dbv.pwszVal, VALUE_LEN);
+ DBFreeVariant(&dbv);
+ } else if(!DBGetContactSettingStringUtf(0, MODULE, setting, &dbv)) {
+ MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, di->value, VALUE_LEN);
+ DBFreeVariant(&dbv);
+ } else if(!DBGetContactSetting(0, MODULE, setting, &dbv)) {
+ MultiByteToWideChar(code_page, 0, dbv.pszVal, -1, di->value, VALUE_LEN);
+ DBFreeVariant(&dbv);
+ }
+
+ di->value[VALUE_LEN - 1] = 0;
+
+ mir_snprintf(setting, 512, "DILineAbove%d", index);
+ di->line_above = (DBGetContactSettingByte(0, MODULE, setting, 0) == 1);
+ mir_snprintf(setting, 512, "DIValNewline%d", index);
+ di->value_newline = (DBGetContactSettingByte(0, MODULE, setting, 0) == 1);
+
+ return true;
+}
+
+void SaveDI(DisplayItem *di, int index) {
+ char setting[512];
+ mir_snprintf(setting, 512, "DILabel%d", index);
+ if(DBWriteContactSettingWString(0, MODULE, setting, di->label)) {
+ char buff[LABEL_LEN];
+ WideCharToMultiByte(code_page, 0, di->label, -1, buff, LABEL_LEN, 0, 0);
+ DBWriteContactSettingString(0, MODULE, setting, buff);
+ }
+ mir_snprintf(setting, 512, "DIValue%d", index);
+ if(DBWriteContactSettingWString(0, MODULE, setting, di->value)) {
+ char buff[VALUE_LEN];
+ WideCharToMultiByte(code_page, 0, di->value, -1, buff, VALUE_LEN, 0, 0);
+ DBWriteContactSettingString(0, MODULE, setting, buff);
+ }
+ mir_snprintf(setting, 512, "DILineAbove%d", index);
+ DBWriteContactSettingByte(0, MODULE, setting, di->line_above ? 1 : 0);
+ mir_snprintf(setting, 512, "DIValNewline%d", index);
+ DBWriteContactSettingByte(0, MODULE, setting, di->value_newline ? 1 : 0);
+}
+
+void SaveOptions() {
+ DBWriteContactSettingDword(0, MODULE, "MaxWidth", options.win_width);
+ DBWriteContactSettingDword(0, MODULE, "MaxHeight", options.win_max_height);
+ DBWriteContactSettingByte(0, MODULE, "Opacity", (BYTE)options.opacity);
+ DBWriteContactSettingByte(0, MODULE, "Border", (options.border ? 1 : 0));
+ DBWriteContactSettingByte(0, MODULE, "DropShadow", (options.drop_shadow ? 1 : 0));
+ DBWriteContactSettingByte(0, MODULE, "RoundCorners", (options.round ? 1 : 0));
+ DBWriteContactSettingByte(0, MODULE, "AvatarRoundCorners", (options.av_round ? 1 : 0));
+ DBWriteContactSettingByte(0, MODULE, "Animate", (options.animate ? 1 : 0));
+ DBWriteContactSettingByte(0, MODULE, "TransparentBg", (options.trans_bg ? 1 : 0));
+ DBWriteContactSettingByte(0, MODULE, "TitleLayout", (BYTE)options.title_layout);
+ if(ServiceExists(MS_AV_DRAWAVATAR))
+ DBWriteContactSettingByte(0, MODULE, "AVLayout", (BYTE)options.av_layout);
+ DBWriteContactSettingDword(0, MODULE, "AVSize", options.av_size);
+ DBWriteContactSettingDword(0, MODULE, "TextIndent", options.text_indent);
+ DBWriteContactSettingByte(0, MODULE, "ShowNoFocus", (options.show_no_focus ? 1 : 0));
+
+ int index = 0;
+ DSListNode *ds_node = options.ds_list;
+ while(ds_node) {
+ SaveDS(&ds_node->ds, index);
+ ds_node = ds_node->next;
+ index++;
+ }
+ DBWriteContactSettingWord(0, MODULE, "DSNumValues", index);
+
+ index = 0;
+ DIListNode *di_node = options.di_list;
+ while(di_node) {
+ SaveDI(&di_node->di, index);
+ di_node = di_node->next;
+ index++;
+ }
+ DBWriteContactSettingWord(0, MODULE, "DINumValues", index);
+
+ DBWriteContactSettingWord(0, MODULE, "TimeIn", options.time_in);
+ CallService(MS_CLC_SETINFOTIPHOVERTIME, options.time_in, 0);
+
+ DBWriteContactSettingWord(0, MODULE, "Padding", options.padding);
+ DBWriteContactSettingWord(0, MODULE, "AvatarPadding", options.av_padding);
+ DBWriteContactSettingWord(0, MODULE, "TextPadding", options.text_padding);
+ DBWriteContactSettingByte(0, MODULE, "Position", (BYTE)options.pos);
+ DBWriteContactSettingDword(0, MODULE, "MinWidth", (DWORD)options.min_width);
+ DBWriteContactSettingDword(0, MODULE, "MinHeight", (DWORD)options.min_height);
+ DBWriteContactSettingDword(0, MODULE, "SidebarWidth", (DWORD)options.sidebar_width);
+ DBWriteContactSettingByte(0, MODULE, "MouseTollerance", (BYTE)options.mouse_tollerance);
+ DBWriteContactSettingByte(0, MODULE, "SBarTips", (options.status_bar_tips ? 1 : 0));
+
+ DBWriteContactSettingWord(0, MODULE, "LabelVAlign", options.label_valign);
+ DBWriteContactSettingWord(0, MODULE, "LabelHAlign", options.label_halign);
+ DBWriteContactSettingWord(0, MODULE, "ValueVAlign", options.value_valign);
+ DBWriteContactSettingWord(0, MODULE, "ValueHAlign", options.value_halign);
+}
+
+void LoadOptions() {
+ options.win_width = DBGetContactSettingDword(0, MODULE, "MaxWidth", 420);
+ options.win_max_height = DBGetContactSettingDword(0, MODULE, "MaxHeight", 400);
+ options.opacity = DBGetContactSettingByte(0, MODULE, "Opacity", 75);
+ options.border = (DBGetContactSettingByte(0, MODULE, "Border", 1) == 1);
+ options.drop_shadow = (DBGetContactSettingByte(0, MODULE, "DropShadow", 1) == 1);
+ options.round = (DBGetContactSettingByte(0, MODULE, "RoundCorners", 1) == 1);
+ options.av_round = (DBGetContactSettingByte(0, MODULE, "AvatarRoundCorners", options.round ? 1 : 0) == 1);
+ options.animate = (DBGetContactSettingByte(0, MODULE, "Animate", 0) == 1);
+ options.trans_bg = (DBGetContactSettingByte(0, MODULE, "TransparentBg", 0) == 1);
+ options.title_layout = (PopupTitleLayout)DBGetContactSettingByte(0, MODULE, "TitleLayout", (BYTE)PTL_LEFTICON);
+ if(ServiceExists(MS_AV_DRAWAVATAR))
+ options.av_layout = (PopupAvLayout)DBGetContactSettingByte(0, MODULE, "AVLayout", PAV_RIGHT);
+ else
+ options.av_layout = PAV_NONE;
+ options.av_size = DBGetContactSettingDword(0, MODULE, "AVSize", 60); //tweety
+ options.text_indent = DBGetContactSettingDword(0, MODULE, "TextIndent", 22);
+ options.sidebar_width = DBGetContactSettingDword(0, MODULE, "SidebarWidth", 22);
+ options.show_no_focus = (DBGetContactSettingByte(0, MODULE, "ShowNoFocus", 1) == 1);
+
+ int real_count = 0;
+ options.ds_list = 0;
+ DSListNode *ds_node;
+ options.ds_count = DBGetContactSettingWord(0, MODULE, "DSNumValues", 0);
+ for(int i = options.ds_count - 1; i >= 0; i--) {
+ ds_node = (DSListNode *)malloc(sizeof(DSListNode));
+ if(LoadDS(&ds_node->ds, i)) {
+ ds_node->next = options.ds_list;
+ options.ds_list = ds_node;
+ real_count++;
+ } else free(ds_node);
+ }
+ options.ds_count = real_count;
+
+ real_count = 0;
+ options.di_list = 0;
+ DIListNode *di_node;
+ options.di_count = DBGetContactSettingWord(0, MODULE, "DINumValues", 0);
+ for(int i = options.di_count - 1; i >= 0; i--) {
+ di_node = (DIListNode *)malloc(sizeof(DIListNode));
+ if(LoadDI(&di_node->di, i)) {
+ di_node->next = options.di_list;
+ options.di_list = di_node;
+ real_count++;
+ } else free(di_node);
+ }
+ options.di_count = real_count;
+
+ options.time_in = DBGetContactSettingWord(0, MODULE, "TimeIn", 750);
+ options.padding = DBGetContactSettingWord(0, MODULE, "Padding", 4);
+ options.av_padding = DBGetContactSettingWord(0, MODULE, "AvatarPadding", 6);
+ options.text_padding = DBGetContactSettingWord(0, MODULE, "TextPadding", 4);
+ options.pos = (PopupPosition)DBGetContactSettingByte(0, MODULE, "Position", (BYTE)PP_BOTTOMRIGHT);
+ options.min_width = DBGetContactSettingDword(0, MODULE, "MinWidth", 0);
+ options.min_height = DBGetContactSettingDword(0, MODULE, "MinHeight", 0);
+
+ options.mouse_tollerance = DBGetContactSettingByte(0, MODULE, "MouseTollerance", (BYTE)GetSystemMetrics(SM_CXSMICON));
+ options.status_bar_tips = (DBGetContactSettingByte(0, MODULE, "SBarTips", 1) == 1);
+
+ // convert defunct last message and status message options to new 'sys' items, and remove the old settings
+ if(DBGetContactSettingByte(0, MODULE, "ShowLastMessage", 0)) {
+ DBDeleteContactSetting(0, MODULE, "ShowLastMessage");
+
+ // find end of list
+ di_node = options.di_list;
+ while(di_node && di_node->next) di_node = di_node->next;
+
+ // last message item
+ if(di_node) {
+ di_node->next = (DIListNode *)malloc(sizeof(DIListNode));
+ di_node = di_node->next;
+ } else {
+ options.di_list = (DIListNode *)malloc(sizeof(DIListNode));
+ di_node = options.di_list;
+ }
+
+ _tcsncpy(di_node->di.label, _T("Last message: (%sys:last_msg_reltime% ago)"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%sys:last_msg%"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = true;
+ di_node->next = 0;
+ options.di_count++;
+ }
+
+ if(DBGetContactSettingByte(0, MODULE, "ShowStatusMessage", 0)) {
+ DBDeleteContactSetting(0, MODULE, "ShowStatusMessage");
+
+ // find end of list
+ di_node = options.di_list;
+ while(di_node && di_node->next) di_node = di_node->next;
+
+ // status message item
+ if(di_node) {
+ di_node->next = (DIListNode *)malloc(sizeof(DIListNode));
+ di_node = di_node->next;
+ } else {
+ options.di_list = (DIListNode *)malloc(sizeof(DIListNode));
+ di_node = options.di_list;
+ }
+
+ _tcsncpy(di_node->di.label, _T("Status message:"), LABEL_LEN);
+ _tcsncpy(di_node->di.value, _T("%sys:status_msg%"), VALUE_LEN);
+ di_node->di.line_above = di_node->di.value_newline = true;
+ di_node->next = 0;
+ options.di_count++;
+ }
+
+ options.label_valign = DBGetContactSettingWord(0, MODULE, "LabelVAlign", DT_TOP /*DT_VCENTER*/);
+ options.label_halign = DBGetContactSettingWord(0, MODULE, "LabelHAlign", DT_LEFT);
+ options.value_valign = DBGetContactSettingWord(0, MODULE, "ValueVAlign", DT_TOP /*DT_VCENTER*/);
+ options.value_halign = DBGetContactSettingWord(0, MODULE, "ValueHAlign", DT_LEFT);
+
+ if(options.ds_count == 0 && options.di_count == 0 && DBGetContactSettingByte(0, MODULE, "DefaultsCreated", 0) == 0) {
+ // set up some reasonable defaults - but only 'once'
+ CreateDefaultItems();
+ DBWriteContactSettingByte(0, MODULE, "DefaultsCreated", 1);
+ SaveOptions();
+ }
+
+}
+
+static BOOL CALLBACK DlgProcAddItem(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ DisplayItem *di = (DisplayItem *)GetWindowLong(hwndDlg, GWL_USERDATA);
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ di = (DisplayItem *)lParam;
+ SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)di);
+
+ SetDlgItemText(hwndDlg, IDC_ED_LABEL, di->label);
+ SetDlgItemText(hwndDlg, IDC_ED_VALUE, di->value);
+
+ CheckDlgButton(hwndDlg, IDC_CHK_LINEABOVE, di->line_above ? TRUE : FALSE);
+ CheckDlgButton(hwndDlg, IDC_CHK_VALNEWLINE, di->value_newline ? TRUE : FALSE);
+ SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL));
+ return TRUE;
+ case WM_COMMAND:
+ if(HIWORD(wParam) == BN_CLICKED) {
+ switch(LOWORD(wParam)) {
+ case IDOK:
+ GetDlgItemText(hwndDlg, IDC_ED_LABEL, di->label, LABEL_LEN);
+ GetDlgItemText(hwndDlg, IDC_ED_VALUE, di->value, VALUE_LEN);
+
+ di->line_above = (IsDlgButtonChecked(hwndDlg, IDC_CHK_LINEABOVE) ? true : false);
+ di->value_newline = (IsDlgButtonChecked(hwndDlg, IDC_CHK_VALNEWLINE) ? true : false);
+
+ EndDialog(hwndDlg, IDOK);
+ return TRUE;
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ return TRUE;
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+static BOOL CALLBACK DlgProcAddSubst(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ DisplaySubst *ds = (DisplaySubst *)GetWindowLong(hwndDlg, GWL_USERDATA);
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ ds = (DisplaySubst *)lParam;
+ SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)ds);
+
+ SetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->name);
+
+ switch(ds->type) {
+ case DVT_PROTODB:
+ CheckDlgButton(hwndDlg, IDC_CHK_PROTOMOD, TRUE);
+ SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->setting_name);
+ break;
+ case DVT_DB:
+ SetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->module_name);
+ SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->setting_name);
+ break;
+ }
+
+ {
+ int index, id;
+ for(int i = 0; i < num_tfuncs; i++) {
+ index = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_ADDSTRING, (WPARAM)-1, (LPARAM)TranslateTS(translations[i].name));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETITEMDATA, index, (LPARAM)translations[i].id);
+ }
+ for(int i = 0; i < num_tfuncs; i++) {
+ id = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, i, 0);
+ if(id == ds->translate_func_id)
+ SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETCURSEL, i, 0);
+ }
+
+ }
+
+ SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0);
+ SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL));
+ return TRUE;
+ case WMU_ENABLE_MODULE_ENTRY:
+ {
+ HWND hw = GetDlgItem(hwndDlg, IDC_CHK_PROTOMOD);
+ EnableWindow(hw, TRUE);
+ hw = GetDlgItem(hwndDlg, IDC_ED_MODULE);
+ EnableWindow(hw, !IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD));
+ hw = GetDlgItem(hwndDlg, IDC_ED_SETTING);
+ EnableWindow(hw, TRUE);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == CBN_SELCHANGE) {
+ return TRUE;
+ } else if(HIWORD(wParam) == BN_CLICKED) {
+ switch(LOWORD(wParam)) {
+ case IDC_CHK_PROTOMOD:
+ SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0);
+ break;
+ case IDOK:
+ GetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->name, LABEL_LEN);
+ if(ds->name[0] == 0) {
+ MessageBox(hwndDlg, TranslateT("You must enter a label"), TranslateT("Invalid Substitution"), MB_OK | MB_ICONWARNING);
+ return TRUE;
+ }
+
+ if(IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD))
+ ds->type = DVT_PROTODB;
+ else {
+ ds->type = DVT_DB;
+ GetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->module_name, MODULE_NAME_LEN);
+ }
+ GetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->setting_name, SETTING_NAME_LEN);
+
+ {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETCURSEL, 0, 0);
+ ds->translate_func_id = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, sel, 0);
+ }
+
+ EndDialog(hwndDlg, IDOK);
+ return TRUE;
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ return TRUE;
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+static BOOL CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ {
+ int index;
+ DIListNode *di_node = options.di_list, *di_value;
+ while(di_node) {
+ di_value = (DIListNode *)malloc(sizeof(DIListNode));
+ *di_value = *di_node;
+ if(di_value->di.label[0] == 0)
+ index = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_ADDSTRING, 0, (LPARAM)TranslateT("<No Label>"));
+ else
+ index = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_ADDSTRING, 0, (LPARAM)di_value->di.label);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETITEMDATA, index, (LPARAM)di_value);
+
+ di_node = di_node->next;
+ }
+
+ DSListNode *ds_node = options.ds_list, *ds_value;
+ while(ds_node) {
+ ds_value = (DSListNode *)malloc(sizeof(DSListNode));
+ *ds_value = *ds_node;
+ index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)ds_value->ds.name);
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)ds_value);
+
+ ds_node = ds_node->next;
+ }
+ }
+
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ return FALSE;
+ case WMU_ENABLE_LIST_BUTTONS:
+ {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCURSEL, 0, 0);
+ if(sel == -1) {
+ HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_UP);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT);
+ EnableWindow(hw, FALSE);
+ } else {
+ int count = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCOUNT, 0, 0);
+ HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE);
+ EnableWindow(hw, TRUE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_UP);
+ EnableWindow(hw, sel > 0);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_DOWN);
+ EnableWindow(hw, sel < count - 1);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT);
+ EnableWindow(hw, TRUE);
+ }
+
+ sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0);
+ if(sel == -1) {
+ HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE2);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT2);
+ EnableWindow(hw, FALSE);
+ } else {
+ HWND hw = GetDlgItem(hwndDlg, IDC_BTN_REMOVE2);
+ EnableWindow(hw, TRUE);
+ hw = GetDlgItem(hwndDlg, IDC_BTN_EDIT2);
+ EnableWindow(hw, TRUE);
+ }
+ }
+ return TRUE;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LST_ITEMS) {
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ } else if ( HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LST_SUBST) {
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ } else if ( HIWORD( wParam ) == CBN_SELCHANGE) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ } else if ( HIWORD( wParam) == LBN_DBLCLK && LOWORD(wParam) == IDC_LST_ITEMS) {
+ {
+ DIListNode *value;
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ value = (DIListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETITEMDATA, sel, 0);
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&value->di) == IDOK) {
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_DELETESTRING, (WPARAM)sel, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_INSERTSTRING, sel, (LPARAM)value->di.label);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETITEMDATA, sel, (LPARAM)value);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETCURSEL, sel, 0);
+
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ }
+ } else if ( HIWORD( wParam) == LBN_DBLCLK && LOWORD(wParam) == IDC_LST_SUBST) {
+ {
+ DSListNode *value;
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0);
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&value->ds) == IDOK) {
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0);
+
+ sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)value->ds.name);
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, sel, (LPARAM)value);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, sel, 0);
+
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ }
+ } else if ( HIWORD( wParam ) == BN_CLICKED ) {
+ switch(LOWORD(wParam)) {
+ case IDC_BTN_ADD:
+ {
+ DIListNode *value = (DIListNode *)malloc(sizeof(DIListNode));
+ memset(value, 0, sizeof(DIListNode));
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&value->di) == IDOK) {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCURSEL, 0, 0), index = sel + 1;
+ if(value->di.label[0] == 0)
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_INSERTSTRING, index, (LPARAM)TranslateT("<No Label>"));
+ else
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_INSERTSTRING, index, (LPARAM)value->di.label);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETITEMDATA, index, (LPARAM)value);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETCURSEL, index, 0);
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+
+ }
+ return TRUE;
+ case IDC_BTN_REMOVE:
+ {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ DIListNode *value = (DIListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETITEMDATA, sel, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_DELETESTRING, (WPARAM)sel, 0);
+ free(value);
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ return TRUE;
+ case IDC_BTN_UP:
+ {
+ DIListNode *value_up;
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCURSEL, 0, 0);
+ if(sel > 0) {
+ value_up = (DIListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETITEMDATA, sel - 1, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_DELETESTRING, (WPARAM)sel - 1, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_INSERTSTRING, sel, (LPARAM)value_up->di.label);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETITEMDATA, sel, (LPARAM)value_up);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETCURSEL, sel - 1, 0);
+ }
+ }
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ case IDC_BTN_DOWN:
+ {
+ DIListNode *value_down;
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCURSEL, 0, 0);
+ int count = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCOUNT, 0, 0);
+ if(sel < count - 1) {
+ value_down = (DIListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETITEMDATA, sel + 1, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_DELETESTRING, (WPARAM)sel + 1, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_INSERTSTRING, sel, (LPARAM)value_down->di.label);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETITEMDATA, sel, (LPARAM)value_down);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETCURSEL, sel + 1, 0);
+ }
+ }
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ case IDC_BTN_EDIT:
+ {
+ DIListNode *value;
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ value = (DIListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETITEMDATA, sel, 0);
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ITEM), hwndDlg, DlgProcAddItem, (LPARAM)&value->di) == IDOK) {
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_DELETESTRING, (WPARAM)sel, 0);
+
+ if(value->di.label[0] == 0)
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_INSERTSTRING, sel, (LPARAM)TranslateT("<No Label>"));
+ else
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_INSERTSTRING, sel, (LPARAM)value->di.label);
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETITEMDATA, sel, (LPARAM)value);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_SETCURSEL, sel, 0);
+
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ }
+ return TRUE;
+
+ case IDC_BTN_ADD2:
+ {
+ DSListNode *value = (DSListNode *)malloc(sizeof(DSListNode));
+ memset(value, 0, sizeof(DSListNode));
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&value->ds) == IDOK) {
+ int index = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)value->ds.name);
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, index, (LPARAM)value);
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, index, 0);
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+
+ }
+ return TRUE;
+ case IDC_BTN_REMOVE2:
+ {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ DSListNode *value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0);
+ free(value);
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ return TRUE;
+ case IDC_BTN_EDIT2:
+ {
+ DSListNode *value;
+ int sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCURSEL, 0, 0);
+ if(sel != -1) {
+ value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, sel, 0);
+ if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SUBST), hwndDlg, DlgProcAddSubst, (LPARAM)&value->ds) == IDOK) {
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_DELETESTRING, (WPARAM)sel, 0);
+
+ sel = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_ADDSTRING, 0, (LPARAM)value->ds.name);
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETITEMDATA, sel, (LPARAM)value);
+
+ SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_SETCURSEL, sel, 0);
+
+ SendMessage(hwndDlg, WMU_ENABLE_LIST_BUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ }
+ return TRUE;
+ default:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
+ }
+ break;
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) {
+ DIListNode *di_node;
+ while(options.di_list) {
+ di_node = options.di_list;
+ options.di_list = options.di_list->next;
+ free(di_node);
+ }
+
+ DIListNode *di_value;
+ options.di_count = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCOUNT, 0, 0);
+ for(int i = options.di_count - 1; i >= 0; i--) {
+ di_node = (DIListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETITEMDATA, i, 0);
+ di_value = (DIListNode *)malloc(sizeof(DIListNode));
+ *di_value = *di_node;
+
+ di_value->next = options.di_list;
+ options.di_list = di_value;
+ }
+
+ DSListNode *ds_node;
+ while(options.ds_list) {
+ ds_node = options.ds_list;
+ options.ds_list = options.ds_list->next;
+ free(ds_node);
+ }
+
+ DSListNode *ds_value;
+ options.ds_count = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCOUNT, 0, 0);
+ for(int i = options.ds_count - 1; i >= 0; i--) {
+ ds_node = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, i, 0);
+ ds_value = (DSListNode *)malloc(sizeof(DSListNode));
+ *ds_value = *ds_node;
+
+ ds_value->next = options.ds_list;
+ options.ds_list = ds_value;
+ }
+
+ SaveOptions();
+ return TRUE;
+ }
+ break;
+ case WM_DESTROY:
+ {
+ DIListNode *di_value;
+ int count = SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETCOUNT, 0, 0);
+ for(int i = 0; i < count; i++) {
+ di_value = (DIListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_ITEMS, LB_GETITEMDATA, i, 0);
+ free(di_value);
+ }
+ DSListNode *ds_value;
+ count = SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETCOUNT, 0, 0);
+ for(int i = 0; i < count; i++) {
+ ds_value = (DSListNode *)SendDlgItemMessage(hwndDlg, IDC_LST_SUBST, LB_GETITEMDATA, i, 0);
+ free(ds_value);
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+
+static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+
+ CheckDlgButton(hwndDlg, IDC_CHK_NOFOCUS, options.show_no_focus ? TRUE : FALSE);
+ CheckDlgButton(hwndDlg, IDC_CHK_SBAR, options.status_bar_tips ? TRUE : FALSE);
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No icon"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No title"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (int)options.title_layout, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_SETCURSEL, (int)options.pos, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Centre"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom"));
+ switch(options.label_valign) {
+ case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 0, 0); break;
+ case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 1, 0); break;
+ case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 2, 0); break;
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Centre"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom"));
+ switch(options.value_valign) {
+ case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 0, 0); break;
+ case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 1, 0); break;
+ case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 2, 0); break;
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right"));
+ switch(options.label_halign) {
+ case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 0, 0); break;
+ case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 1, 0); break;
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right"));
+ switch(options.value_halign) {
+ case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 0, 0); break;
+ case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 1, 0); break;
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar"));
+ if(ServiceExists(MS_AV_DRAWAVATAR)) {
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar"));
+ } else {
+ HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE);
+ EnableWindow(hw, FALSE);
+ }
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)options.av_layout, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_MINWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_MINHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(99, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_TEXTPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_AVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_HOVER, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 5));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0));
+
+ SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, options.win_width, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, options.win_max_height, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, options.min_width, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, options.min_height, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, options.av_size, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_INDENT, options.text_indent, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_PADDING, options.padding, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, options.text_padding, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_AVPADDING, options.av_padding, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_HOVER, options.time_in, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, options.sidebar_width, FALSE);
+
+ SetDlgItemInt(hwndDlg, IDC_ED_TRANS, options.opacity, FALSE);
+ CheckDlgButton(hwndDlg, IDC_CHK_BORDER, options.border);
+ CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, options.round);
+ CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, options.av_round);
+
+ CheckDlgButton(hwndDlg, IDC_CHK_ANIMATE, options.animate);
+ CheckDlgButton(hwndDlg, IDC_CHK_SHADOW, options.drop_shadow);
+ CheckDlgButton(hwndDlg, IDC_CHK_TRANSBG, options.trans_bg);
+
+ return FALSE;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == CBN_SELCHANGE) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ } else if ( HIWORD( wParam ) == BN_CLICKED ) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) {
+ BOOL trans;
+ int new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE);
+ if(trans) options.win_width = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE);
+ if(trans) options.min_width = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE);
+ if(trans) options.win_max_height = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, &trans, FALSE);
+ if(trans) options.min_height = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE);
+ if(trans) options.av_size = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE);
+ if(trans) options.text_indent = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE);
+ if(trans) options.padding = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, &trans, FALSE);
+ if(trans) options.text_padding = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVPADDING, &trans, FALSE);
+ if(trans) options.av_padding = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_HOVER, &trans, FALSE);
+ if(trans) options.time_in = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE);
+ if(trans) options.sidebar_width = new_val;
+
+ options.title_layout = (PopupTitleLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0);
+ options.av_layout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0);
+ options.pos = (PopupPosition)SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_GETCURSEL, 0, 0);
+
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, &trans, FALSE);
+ if(trans) options.opacity = new_val;
+ options.border = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_BORDER)) ? true : false;
+ options.round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERS)) ? true : false;
+ options.av_round = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false;
+ options.animate = IsDlgButtonChecked(hwndDlg, IDC_CHK_ANIMATE) ? true : false;
+ options.drop_shadow = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHADOW) ? true : false;
+ options.trans_bg = IsDlgButtonChecked(hwndDlg, IDC_CHK_TRANSBG) ? true : false;
+
+ options.show_no_focus = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOFOCUS) ? true : false;
+ options.status_bar_tips = IsDlgButtonChecked(hwndDlg, IDC_CHK_SBAR) ? true : false;
+
+ switch(SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_GETCURSEL, 0, 0)) {
+ case 0: options.label_valign = DT_TOP; break;
+ case 1: options.label_valign = DT_VCENTER; break;
+ case 2: options.label_valign = DT_BOTTOM; break;
+ }
+ switch(SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_GETCURSEL, 0, 0)) {
+ case 0: options.value_valign = DT_TOP; break;
+ case 1: options.value_valign = DT_VCENTER; break;
+ case 2: options.value_valign = DT_BOTTOM; break;
+ }
+
+ switch(SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_GETCURSEL, 0, 0)) {
+ case 0: options.label_halign = DT_LEFT; break;
+ case 1: options.label_halign = DT_RIGHT; break;
+ }
+ switch(SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_GETCURSEL, 0, 0)) {
+ case 0: options.value_halign = DT_LEFT; break;
+ case 1: options.value_halign = DT_RIGHT; break;
+ }
+
+ SaveOptions();
+ return TRUE;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+int OptInit(WPARAM wParam, LPARAM lParam) {
+ OPTIONSDIALOGPAGE odp = { 0 };
+#define OPTIONPAGE_OLD_SIZE2 60
+ DWORD mirVir = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0);
+ odp.cbSize = (mirVir >= 0x00060000 ? sizeof(odp) : OPTIONPAGE_OLD_SIZE2);
+ //odp.cbSize = sizeof(odp);
+
+ odp.flags = ODPF_BOLDGROUPS;
+ //odp.flags |= ODPF_UNICODE;
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+
+
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1);
+ odp.pszTab = Translate("Appearance");
+ odp.pszTitle = (mirVir >= 0x00060000 ? Translate("Tooltips") : Translate("Tooltips View"));;
+ odp.pszGroup = Translate("Customize");
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOpts1;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT2);
+ odp.pszTab = Translate("Content");
+ odp.pszTitle = (mirVir >= 0x00060000 ? Translate("Tooltips") : Translate("Tooltips Content"));;
+ odp.pszGroup = Translate("Customize");
+ odp.nIDBottomSimpleControl = 0;
+ odp.pfnDlgProc = DlgProcOpts2;
+ CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp );
+
+ return 0;
+}
+
+HANDLE hEventOptInit;
+
+void InitOptions() {
+ hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit);
+}
+
+void DeinitOptions() {
+ UnhookEvent(hEventOptInit);
+
+ DIListNode *di_node = options.di_list;
+ while(options.di_list) {
+ di_node = options.di_list;
+ options.di_list = options.di_list->next;
+ free(di_node);
+ }
+
+ DSListNode *ds_node = options.ds_list;
+ while(options.ds_list) {
+ ds_node = options.ds_list;
+ options.ds_list = options.ds_list->next;
+ free(ds_node);
+ }
+}