summaryrefslogtreecommitdiff
path: root/plugins/DbEditorPP/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/DbEditorPP/src')
-rw-r--r--plugins/DbEditorPP/src/findwindow.cpp54
-rw-r--r--plugins/DbEditorPP/src/main_window.cpp104
-rw-r--r--plugins/DbEditorPP/src/watchedvars.cpp66
3 files changed, 107 insertions, 117 deletions
diff --git a/plugins/DbEditorPP/src/findwindow.cpp b/plugins/DbEditorPP/src/findwindow.cpp
index 8f80063be5..2d21dac0c9 100644
--- a/plugins/DbEditorPP/src/findwindow.cpp
+++ b/plugins/DbEditorPP/src/findwindow.cpp
@@ -35,7 +35,8 @@ static int lastColumn = -1;
#define F_DELETED 0x400
-typedef struct {
+typedef struct
+{
HWND hwnd; // hwnd to item list
wchar_t* search; // text to find
wchar_t* replace; // text to replace
@@ -43,19 +44,18 @@ typedef struct {
} FindInfo;
-ColumnsSettings csResultList[] = {
+ColumnsSettings csResultList[] =
+{
{ LPGENW("Result"), 0, "Search0width", 100 },
{ LPGENW("Contact"), 1, "Search1width", 100 },
{ LPGENW("Module"), 2, "Search2width", 100 },
{ LPGENW("Setting"), 3, "Search3width", 100 },
{ LPGENW("Value"), 4, "Search4width", 150 },
- {nullptr}
+ { nullptr }
};
-
void __cdecl FindSettings(LPVOID di);
-
int FindDialogResize(HWND, LPARAM, UTILRESIZECONTROL *urc)
{
switch (urc->wId) {
@@ -68,9 +68,10 @@ int FindDialogResize(HWND, LPARAM, UTILRESIZECONTROL *urc)
}
}
-
INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ HWND hwndResults = GetDlgItem(hwnd, IDC_LIST);
+
switch (msg) {
case WM_INITDIALOG:
SendDlgItemMessage(hwnd, IDC_SBAR, SB_SETTEXT, 0, (LPARAM)TranslateT("Enter a string to search the database for"));
@@ -83,8 +84,8 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0);
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW); // taskbar icon
TranslateDialogDefault(hwnd);
- ListView_SetExtendedListViewStyle(GetDlgItem(hwnd, IDC_LIST), 32 | LVS_EX_LABELTIP); // LVS_EX_GRIDLINES
- loadListSettings(GetDlgItem(hwnd, IDC_LIST), csResultList);
+ ListView_SetExtendedListViewStyle(hwndResults, 32 | LVS_EX_LABELTIP); // LVS_EX_GRIDLINES
+ loadListSettings(hwndResults, csResultList);
Utils_RestoreWindowPositionNoMove(hwnd, NULL, MODULENAME, "Search_");
return TRUE;
@@ -115,7 +116,7 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
if (!fi)
break;
- fi->hwnd = GetDlgItem(hwnd, IDC_LIST);
+ fi->hwnd = hwndResults;
fi->options = (IsDlgButtonChecked(hwnd, IDC_CASESENSITIVE) ? F_CASE : 0) |
(IsDlgButtonChecked(hwnd, IDC_EXACT) ? F_EXACT : 0) |
(IsDlgButtonChecked(hwnd, IDC_MODNAME) ? F_MODNAME : 0) |
@@ -153,13 +154,14 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
break;
}
break;
+
case WM_GETMINMAXINFO:
- {
- MINMAXINFO *mmi = (MINMAXINFO*)lParam;
- mmi->ptMinTrackSize.x = 610;
- mmi->ptMinTrackSize.y = 300;
- }
- return 0;
+ {
+ MINMAXINFO *mmi = (MINMAXINFO*)lParam;
+ mmi->ptMinTrackSize.x = 610;
+ mmi->ptMinTrackSize.y = 300;
+ }
+ return 0;
case WM_SIZE:
Utils_ResizeDialog(hwnd, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_FIND), FindDialogResize);
@@ -169,19 +171,15 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
if (LOWORD(wParam) != IDC_LIST) break;
switch (((NMHDR*)lParam)->code) {
case NM_DBLCLK:
- {
LVHITTESTINFO hti;
LVITEM lvi;
- HWND hwndResults = GetDlgItem(hwnd, IDC_LIST);
hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
if (ListView_SubItemHitTest(hwndResults, &hti) > -1) {
- if (hti.flags&LVHT_ONITEM)
- {
+ if (hti.flags & LVHT_ONITEM) {
lvi.mask = LVIF_PARAM;
lvi.iItem = hti.iItem;
lvi.iSubItem = 0;
- if (ListView_GetItem(hwndResults, &lvi))
- {
+ if (ListView_GetItem(hwndResults, &lvi)) {
ItemInfo ii = { 0 };
ii.hContact = (MCONTACT)lvi.lParam;
ListView_GetItemTextA(hwndResults, hti.iItem, 2, ii.module, _countof(ii.module));
@@ -196,24 +194,22 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
}
break;
- }
case LVN_COLUMNCLICK:
- {
LPNMLISTVIEW lv = (LPNMLISTVIEW)lParam;
ColumnsSortParams params;
- params.hList = GetDlgItem(hwnd, IDC_LIST);
+ params.hList = hwndResults;
params.column = lv->iSubItem;
params.last = lastColumn;
ListView_SortItemsEx(params.hList, ColumnsCompare, (LPARAM)&params);
lastColumn = (params.column == lastColumn) ? -1 : params.column;
break;
- }
} // switch
break;
+
case WM_DESTROY:
- ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_LIST));
- saveListSettings(GetDlgItem(hwnd, IDC_LIST), csResultList);
+ ListView_DeleteAllItems(hwndResults);
+ saveListSettings(hwndResults, csResultList);
Utils_SaveWindowPosition(hwnd, NULL, MODULENAME, "Search_");
break;
}
@@ -221,7 +217,8 @@ INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
-void newFindWindow() {
+void newFindWindow()
+{
CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FIND), hwnd2mainWindow, FindWindowDlgProc);
}
@@ -564,7 +561,6 @@ void __cdecl FindSettings(LPVOID param)
ItemFound(fi->hwnd, hContact, newModule, nullptr, nullptr, flag);
}
-
} // for(module)
}
diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp
index fbef13920e..2318e21397 100644
--- a/plugins/DbEditorPP/src/main_window.cpp
+++ b/plugins/DbEditorPP/src/main_window.cpp
@@ -60,12 +60,12 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
return HTCLIENT;
case WM_SETCURSOR:
- {
- RECT rc;
- GetClientRect(hwnd, &rc);
- SetCursor(rc.right > rc.bottom ? LoadCursor(nullptr, IDC_SIZENS) : LoadCursor(nullptr, IDC_SIZEWE));
- }
- return TRUE;
+ {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ SetCursor(rc.right > rc.bottom ? LoadCursor(nullptr, IDC_SIZENS) : LoadCursor(nullptr, IDC_SIZEWE));
+ }
+ return TRUE;
case WM_LBUTTONDOWN:
SetCapture(hwnd);
@@ -91,18 +91,18 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
{
switch (msg) {
case WM_RBUTTONDOWN:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(hwnd, &hti.pt);
-
- if (TreeView_HitTest(hwnd, &hti)) {
- if (hti.flags&TVHT_ONITEM)
- TreeView_SelectItem(hwnd, hti.hItem);
+ {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(hwnd, &hti.pt);
+
+ if (TreeView_HitTest(hwnd, &hti)) {
+ if (hti.flags&TVHT_ONITEM)
+ TreeView_SelectItem(hwnd, hti.hItem);
+ }
}
- }
- break;
+ break;
case WM_CHAR:
if (GetKeyState(VK_CONTROL) & 0x8000 && wParam == 6)
@@ -265,38 +265,38 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return TRUE;
case GC_SPLITTERMOVED:
- {
- int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
-
- RECT rc2;
- GetWindowRect(hwnd, &rc2);
-
- if ((HWND)lParam == GetDlgItem(hwnd, IDC_SPLITTER)) {
- RECT rc;
- GetClientRect(hwnd, &rc);
- POINT pt = { (LONG)wParam, 0 };
- ScreenToClient(hwnd, &pt);
-
- splitterPos = rc.left + pt.x + 1;
- if (splitterPos < 150)
- splitterPos = 150;
- if (splitterPos > rc2.right - rc2.left - 150)
- splitterPos = rc2.right - rc2.left - 150;
- SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
- g_plugin.setWord("Splitter", (WORD)splitterPos);
+ {
+ int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
+
+ RECT rc2;
+ GetWindowRect(hwnd, &rc2);
+
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SPLITTER)) {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ POINT pt = { (LONG)wParam, 0 };
+ ScreenToClient(hwnd, &pt);
+
+ splitterPos = rc.left + pt.x + 1;
+ if (splitterPos < 150)
+ splitterPos = 150;
+ if (splitterPos > rc2.right - rc2.left - 150)
+ splitterPos = rc2.right - rc2.left - 150;
+ SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
+ g_plugin.setWord("Splitter", (WORD)splitterPos);
+ }
+ PostMessage(hwnd, WM_SIZE, 0, 0);
}
- PostMessage(hwnd, WM_SIZE, 0, 0);
- }
- break;
+ break;
case WM_GETMINMAXINFO:
- {
- MINMAXINFO *mmi = (MINMAXINFO *)lParam;
- int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
- mmi->ptMinTrackSize.x = splitterPos + 150;
- mmi->ptMinTrackSize.y = 300;
- }
- return 0;
+ {
+ MINMAXINFO *mmi = (MINMAXINFO *)lParam;
+ int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
+ mmi->ptMinTrackSize.x = splitterPos + 150;
+ mmi->ptMinTrackSize.y = 300;
+ }
+ return 0;
case WM_MOVE:
case WM_SIZE:
@@ -490,12 +490,12 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED));
break;
case MENU_SAVE_POSITION:
- {
- BOOL save = !g_plugin.getByte("RestoreOnOpen", 1);
- CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED));
- g_plugin.setByte("RestoreOnOpen", (byte)save);
- }
- break;
+ {
+ BOOL save = !g_plugin.getByte("RestoreOnOpen", 1);
+ CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED));
+ g_plugin.setByte("RestoreOnOpen", (byte)save);
+ }
+ break;
case MENU_INLINE_EDIT:
g_Inline = !g_Inline;
CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_INLINE_EDIT, MF_BYCOMMAND | (g_Inline ? MF_CHECKED : MF_UNCHECKED));
diff --git a/plugins/DbEditorPP/src/watchedvars.cpp b/plugins/DbEditorPP/src/watchedvars.cpp
index f24dad1745..7cd8ef85b5 100644
--- a/plugins/DbEditorPP/src/watchedvars.cpp
+++ b/plugins/DbEditorPP/src/watchedvars.cpp
@@ -17,7 +17,8 @@ ColumnsSettings csWatchList[] = {
-int WatchedArrayIndex(MCONTACT hContact, const char *module, const char *setting, int strict) {
+int WatchedArrayIndex(MCONTACT hContact, const char *module, const char *setting, int strict)
+{
for (int i = 0; i < WatchListArray.count; i++) {
if (hContact == WatchListArray.item[i].hContact)
if (!mir_strcmp(module, WatchListArray.item[i].module))
@@ -31,8 +32,7 @@ int WatchedArrayIndex(MCONTACT hContact, const char *module, const char *setting
int addSettingToWatchList(MCONTACT hContact, const char *module, const char *setting)
{
- if (WatchListArray.count == WatchListArray.size)
- {
+ if (WatchListArray.count == WatchListArray.size) {
WatchListArray.size += 32;
WatchListArray.item = (struct DBsetting*)mir_realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size);
}
@@ -94,8 +94,7 @@ void addwatchtolist(HWND hwnd, struct DBsetting *lParam)
dummy.hContact = lParam->hContact;
dummy.module = lParam->module;
- for (ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next)
- {
+ for (ModSetLinkLinkItem *setting = settinglist.first; setting; setting = setting->next) {
dummy.setting = setting->name;
addwatchtolist(hwnd, &dummy);
@@ -125,11 +124,11 @@ void addwatchtolist(HWND hwnd, struct DBsetting *lParam)
switch (dbv->type) {
case DBVT_BLOB:
- {
- ptrA str(StringFromBlob(dbv->pbVal, dbv->cpbVal));
- ListView_SetItemTextA(hwnd, index, 3, str);
- break;
- }
+ {
+ ptrA str(StringFromBlob(dbv->pbVal, dbv->cpbVal));
+ ListView_SetItemTextA(hwnd, index, 3, str);
+ break;
+ }
case DBVT_BYTE:
mir_snwprintf(data, L"0x%02X (%s)", dbv->bVal, _ultow(dbv->bVal, tmp, 10));
ListView_SetItemText(hwnd, index, 3, data);
@@ -149,18 +148,18 @@ void addwatchtolist(HWND hwnd, struct DBsetting *lParam)
break;
case DBVT_WCHAR:
- {
- ptrW str(mir_wstrdup(dbv->pwszVal));
- ListView_SetItemText(hwnd, index, 3, str);
- break;
- }
+ {
+ ptrW str(mir_wstrdup(dbv->pwszVal));
+ ListView_SetItemText(hwnd, index, 3, str);
+ break;
+ }
case DBVT_UTF8:
- {
- ptrW str(mir_utf8decodeW(dbv->pszVal));
- ListView_SetItemText(hwnd, index, 3, str);
- break;
- }
+ {
+ ptrW str(mir_utf8decodeW(dbv->pszVal));
+ ListView_SetItemText(hwnd, index, 3, str);
+ break;
+ }
case DBVT_DELETED:
if (IsResidentSetting(lParam->module, lParam->setting))
ListView_SetItemText(hwnd, index, 3, TranslateT("*** resident ***"));
@@ -192,8 +191,7 @@ void PopulateWatchedWindow()
void freeAllWatches()
{
ListView_DeleteAllItems(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS));
- for (int i = 0; i < WatchListArray.count; i++)
- {
+ for (int i = 0; i < WatchListArray.count; i++) {
freeWatchListItem(i);
}
mir_free(WatchListArray.item);
@@ -204,8 +202,7 @@ void freeAllWatches()
int WatchDialogResize(HWND, LPARAM, UTILRESIZECONTROL *urc)
{
- switch (urc->wId)
- {
+ switch (urc->wId) {
case IDC_VARS:
urc->rcItem.top = 0;
urc->rcItem.bottom = urc->dlgNewSize.cy;
@@ -256,12 +253,12 @@ INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
// for the resize
case WM_GETMINMAXINFO:
- {
- MINMAXINFO *mmi = (MINMAXINFO*)lParam;
- mmi->ptMinTrackSize.x = 500;
- mmi->ptMinTrackSize.y = 300;
- }
- return 0;
+ {
+ MINMAXINFO *mmi = (MINMAXINFO*)lParam;
+ mmi->ptMinTrackSize.x = 500;
+ mmi->ptMinTrackSize.y = 300;
+ }
+ return 0;
case WM_SIZE:
Utils_ResizeDialog(hwnd, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_WATCH_DIAG), WatchDialogResize);
@@ -292,15 +289,12 @@ INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndVars = GetDlgItem(hwnd, IDC_VARS);
hti.pt = ((NMLISTVIEW*)lParam)->ptAction;
- if (ListView_SubItemHitTest(hwndVars, &hti) > -1)
- {
- if (hti.flags&LVHT_ONITEM)
- {
+ if (ListView_SubItemHitTest(hwndVars, &hti) > -1) {
+ if (hti.flags&LVHT_ONITEM) {
lvi.mask = LVIF_PARAM;
lvi.iItem = hti.iItem;
lvi.iSubItem = 0;
- if (ListView_GetItem(hwndVars, &lvi))
- {
+ if (ListView_GetItem(hwndVars, &lvi)) {
ItemInfo ii;
ii.hContact = (MCONTACT)lvi.lParam;
ListView_GetItemTextA(hwndVars, hti.iItem, 1, ii.module, _countof(ii.module));