diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-13 19:55:02 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-13 20:46:01 +0300 |
commit | 887544273011d56a796e9507199ea8d6484d31c6 (patch) | |
tree | c203b7f58e69abad45de75ed5e3e75f99057a17d /plugins/NewStory/src | |
parent | cd99f666712ff1227e33d8891897c4f4409dd572 (diff) |
NewStory: code cleaning
Diffstat (limited to 'plugins/NewStory/src')
-rw-r--r-- | plugins/NewStory/src/calendartool.cpp | 78 | ||||
-rw-r--r-- | plugins/NewStory/src/fonts.cpp | 14 | ||||
-rw-r--r-- | plugins/NewStory/src/history.cpp | 870 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 115 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 109 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 774 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/icons.cpp | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/main.cpp | 29 | ||||
-rw-r--r-- | plugins/NewStory/src/opt_passwords.cpp | 48 | ||||
-rw-r--r-- | plugins/NewStory/src/options.cpp | 160 | ||||
-rw-r--r-- | plugins/NewStory/src/options.h | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/password.cpp | 180 | ||||
-rw-r--r-- | plugins/NewStory/src/quicklist.h | 6 | ||||
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 368 | ||||
-rw-r--r-- | plugins/NewStory/src/templates.h | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.cpp | 42 |
17 files changed, 1208 insertions, 1598 deletions
diff --git a/plugins/NewStory/src/calendartool.cpp b/plugins/NewStory/src/calendartool.cpp index c9ca60ab64..3a44db032a 100644 --- a/plugins/NewStory/src/calendartool.cpp +++ b/plugins/NewStory/src/calendartool.cpp @@ -8,49 +8,37 @@ struct CalendarToolData INT_PTR CALLBACK CalendarToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { CalendarToolData *data = (CalendarToolData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - switch (msg) - { - case WM_INITDIALOG: - { - data = (CalendarToolData *)lParam; - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); - -// This causes ALL miranda dialogs to have drop-shadow enabled. That's bad =( -// SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE)|CS_DROPSHADOW); + switch (msg) { + case WM_INITDIALOG: + data = (CalendarToolData *)lParam; + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); - SetWindowPos(hwnd, HWND_TOP, data->x, data->y, 0, 0, SWP_NOSIZE); - return TRUE; - } + // This causes ALL miranda dialogs to have drop-shadow enabled. That's bad =( + // SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE)|CS_DROPSHADOW); + SetWindowPos(hwnd, HWND_TOP, data->x, data->y, 0, 0, SWP_NOSIZE); + return TRUE; - case WM_ACTIVATE: - if (wParam == WA_INACTIVE) - PostMessage(hwnd, WM_CLOSE, 0, 0); - break; + case WM_ACTIVATE: + if (wParam == WA_INACTIVE) + PostMessage(hwnd, WM_CLOSE, 0, 0); + break; - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDOK: - { - EndDialog(hwnd, 0); - return TRUE; - } + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + EndDialog(hwnd, 0); + return TRUE; - case IDCANCEL: - { - EndDialog(hwnd, 0); - return TRUE; - } - } - break; + case IDCANCEL: + EndDialog(hwnd, 0); + return TRUE; } + break; - case WM_NOTIFY: + case WM_NOTIFY: { LPNMHDR hdr = (LPNMHDR)lParam; - if ((hdr->idFrom = IDC_MONTHCALENDAR1) && (hdr->code == MCN_SELECT)) - { + if ((hdr->idFrom = IDC_MONTHCALENDAR1) && (hdr->code == MCN_SELECT)) { LPNMSELCHANGE lpnmsc = (LPNMSELCHANGE)lParam; struct tm tm_sel; tm_sel.tm_hour = tm_sel.tm_min = tm_sel.tm_sec = 0; @@ -63,18 +51,14 @@ INT_PTR CALLBACK CalendarToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return TRUE; } - case WM_CLOSE: - { - DestroyWindow(hwnd); - return TRUE; - } + case WM_CLOSE: + DestroyWindow(hwnd); + return TRUE; - case WM_DESTROY: - { - delete data; - data = 0; - SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - } + case WM_DESTROY: + delete data; + data = 0; + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); } return FALSE; } @@ -85,4 +69,4 @@ time_t CalendarTool_Show(HWND hwnd, int x, int y) data->x = x; data->y = y; return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CALENDARTOOL), hwnd, CalendarToolDlgProc, (LPARAM)data); -}
\ No newline at end of file +} diff --git a/plugins/NewStory/src/fonts.cpp b/plugins/NewStory/src/fonts.cpp index 515665fa57..39e3f016b4 100644 --- a/plugins/NewStory/src/fonts.cpp +++ b/plugins/NewStory/src/fonts.cpp @@ -4,18 +4,18 @@ MyColourID colors[] = { { "Incoming Messages", "ColorMsgIn", RGB(0xff, 0xff, 0xff) }, { "Outgoing Messages", "ColorMsgOut", RGB(0xff, 0xff, 0xff) }, - + { "Incoming Files", "ColorFileIn", RGB(0xff, 0xff, 0xff) }, { "Outgoing Files", "ColorFileOut", RGB(0xff, 0xff, 0xff) }, - + { "Incoming URLs", "ColorURLIn", RGB(0xff, 0xff, 0xff) }, { "Outgoing URLs", "ColorURLOut", RGB(0xff, 0xff, 0xff) }, - + { "Status changes", "ColorStatus", RGB(0xff, 0xff, 0xff) }, - + { "Other Outgoing Events", "ColorOut", RGB(0xff, 0xff, 0xff) }, { "Other Incoming Events", "ColorIn", RGB(0xff, 0xff, 0xff) }, - + { "Selected Items", "ColorSel", RGB(0x60, 0x60, 0x60) }, { "Selected Items (Text)", "ColorSelTxt", RGB(0xff, 0xff, 0xff) } }; @@ -44,7 +44,7 @@ int evtFontsChanged(WPARAM, LPARAM) for (auto &it : fonts) { it.cl = (COLORREF)Font_Get(MODULENAME, it.szName, &it.lf); - + DeleteObject(it.hfnt); it.hfnt = CreateFontIndirectA(&it.lf); } @@ -82,7 +82,7 @@ void InitFonts() strncpy_s(fontid.name, it.szName, _TRUNCATE); strncpy_s(fontid.setting, it.szSetting, _TRUNCATE); g_plugin.addFont(&fontid); - + it.cl = Font_Get(MODULENAME, it.szName, &it.lf); it.hfnt = CreateFontIndirectA(&it.lf); } diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp index 2f5bd9009a..cb1dd3d2c3 100644 --- a/plugins/NewStory/src/history.cpp +++ b/plugins/NewStory/src/history.cpp @@ -43,21 +43,21 @@ void FreeHistory() enum { - HIST_SHOW_IN = 0x001, - HIST_SHOW_OUT = 0x002, - HIST_SHOW_MSGS = 0x004, - HIST_SHOW_FILES = 0x008, - HIST_SHOW_URLS = 0x010, + HIST_SHOW_IN = 0x001, + HIST_SHOW_OUT = 0x002, + HIST_SHOW_MSGS = 0x004, + HIST_SHOW_FILES = 0x008, + HIST_SHOW_URLS = 0x010, HIST_SHOW_STATUS = 0x020, - HIST_SHOW_OTHER = 0x040, + HIST_SHOW_OTHER = 0x040, HIST_AUTO_FILTER = 0x080, }; enum { - WND_OPT_TIMETREE = 0x01, - WND_OPT_SEARCHBAR = 0x02, - WND_OPT_FILTERBAR = 0x04 + WND_OPT_TIMETREE = 0x01, + WND_OPT_SEARCHBAR = 0x02, + WND_OPT_FILTERBAR = 0x04 }; enum @@ -67,7 +67,7 @@ enum TBTN_SPACER = 10 }; -enum +enum { TBTN_USERINFO, TBTN_USERMENU, TBTN_MESSAGE, TBTN_SEARCH, TBTN_FILTER, TBTN_DATEPOPUP, @@ -76,7 +76,7 @@ enum TBTN_COUNT }; -int tbtnSpacing[TBTN_COUNT] = {0, 0, TBTN_SPACER, 0, 0, TBTN_SPACER, 0, -1, 0, 0, 0}; +int tbtnSpacing[TBTN_COUNT] = { 0, 0, TBTN_SPACER, 0, 0, TBTN_SPACER, 0, -1, 0, 0, 0 }; struct InfoBarEvents { @@ -119,17 +119,17 @@ void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents *ib) hDwp = DeferWindowPos(hDwp, ib->hwndIco, 0, x, y, 16, 16, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, ib->hwndTxt, 0, - x+16+WND_SPACING, y, w-16-WND_SPACING, 16, SWP_NOZORDER); + x + 16 + WND_SPACING, y, w - 16 - WND_SPACING, 16, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, ib->hwndIcoIn, 0, - x+16, y+16+WND_SPACING, 16, 16, SWP_NOZORDER); + x + 16, y + 16 + WND_SPACING, 16, 16, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, ib->hwndTxtIn, 0, - x+32+WND_SPACING, y+16+WND_SPACING, w-WND_SPACING-32, 16, SWP_NOZORDER); + x + 32 + WND_SPACING, y + 16 + WND_SPACING, w - WND_SPACING - 32, 16, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, ib->hwndIcoOut, 0, - x+16, y+(16+WND_SPACING)*2, 16, 16, SWP_NOZORDER); + x + 16, y + (16 + WND_SPACING) * 2, 16, 16, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, ib->hwndTxtOut, 0, - x+32+WND_SPACING, y+(16+WND_SPACING)*2, w-WND_SPACING-32, 16, SWP_NOZORDER); + x + 32 + WND_SPACING, y + (16 + WND_SPACING) * 2, w - WND_SPACING - 32, 16, SWP_NOZORDER); } @@ -190,27 +190,24 @@ void LayoutHistoryWnd(HWND hwnd, WindowData *data) int hToolBar = TBTN_SIZE + WND_SPACING; x = WND_SPACING; int btnReverse = -1; - for (i = 0; i < TBTN_COUNT; ++i) - { + for (i = 0; i < TBTN_COUNT; ++i) { hDwp = DeferWindowPos(hDwp, data->hwndBtnToolbar[i], 0, x, WND_SPACING, TBTN_SIZE, TBTN_SIZE, SWP_NOZORDER); x += TBTN_SIZE + tbtnSpacing[i]; - if (tbtnSpacing[i] < 0) - { + if (tbtnSpacing[i] < 0) { btnReverse = i; break; } } x = w - WND_SPACING - TBTN_SIZE; - for (i = TBTN_COUNT-1; i > btnReverse; --i) - { + for (i = TBTN_COUNT - 1; i > btnReverse; --i) { hDwp = DeferWindowPos(hDwp, data->hwndBtnToolbar[i], 0, x, WND_SPACING, TBTN_SIZE, TBTN_SIZE, SWP_NOZORDER); - x -= TBTN_SIZE + tbtnSpacing[i-1]; + x -= TBTN_SIZE + tbtnSpacing[i - 1]; } // infobar @@ -229,39 +226,38 @@ void LayoutHistoryWnd(HWND hwnd, WindowData *data) // filter bar int hFilterBar = 0; - if (data->wndOptions & WND_OPT_FILTERBAR) - { - hFilterBar = WND_SPACING + (16 + WND_SPACING)*3; - LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*0, WND_SPACING*2 + hToolBar, 75, &data->ibMessages); - LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*1, WND_SPACING*2 + hToolBar, 75, &data->ibFiles); - LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*2, WND_SPACING*2 + hToolBar, 75, &data->ibUrls); - LayoutFilterBar(hDwp, WND_SPACING+(WND_SPACING+75)*3, WND_SPACING*2 + hToolBar, 75, &data->ibTotal); + if (data->wndOptions & WND_OPT_FILTERBAR) { + hFilterBar = WND_SPACING + (16 + WND_SPACING) * 3; + LayoutFilterBar(hDwp, WND_SPACING + (WND_SPACING + 75) * 0, WND_SPACING * 2 + hToolBar, 75, &data->ibMessages); + LayoutFilterBar(hDwp, WND_SPACING + (WND_SPACING + 75) * 1, WND_SPACING * 2 + hToolBar, 75, &data->ibFiles); + LayoutFilterBar(hDwp, WND_SPACING + (WND_SPACING + 75) * 2, WND_SPACING * 2 + hToolBar, 75, &data->ibUrls); + LayoutFilterBar(hDwp, WND_SPACING + (WND_SPACING + 75) * 3, WND_SPACING * 2 + hToolBar, 75, &data->ibTotal); GetWindowRect(data->hwndChkDateFrom, &rc); x = rc.right - rc.left; GetWindowRect(data->hwndDateFrom, &rc); - y = hToolBar + WND_SPACING + (WND_SPACING + (16 + WND_SPACING)*3 - (rc.bottom-rc.top)*2 - WND_SPACING)/2; + y = hToolBar + WND_SPACING + (WND_SPACING + (16 + WND_SPACING) * 3 - (rc.bottom - rc.top) * 2 - WND_SPACING) / 2; hDwp = DeferWindowPos(hDwp, data->hwndChkDateFrom, 0, - w-x-(rc.right-rc.left)-WND_SPACING*2, y, - x, rc.bottom-rc.top, + w - x - (rc.right - rc.left) - WND_SPACING * 2, y, + x, rc.bottom - rc.top, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, data->hwndDateFrom, 0, - w-(rc.right-rc.left)-WND_SPACING, y, - rc.right-rc.left, rc.bottom-rc.top, + w - (rc.right - rc.left) - WND_SPACING, y, + rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, data->hwndChkDateTo, 0, - w-x-(rc.right-rc.left)-WND_SPACING*2, y + (rc.bottom-rc.top) + WND_SPACING, - x, rc.bottom-rc.top, + w - x - (rc.right - rc.left) - WND_SPACING * 2, y + (rc.bottom - rc.top) + WND_SPACING, + x, rc.bottom - rc.top, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, data->hwndDateTo, 0, - w-(rc.right-rc.left)-WND_SPACING, y + (rc.bottom-rc.top) + WND_SPACING, - rc.right-rc.left, rc.bottom-rc.top, + w - (rc.right - rc.left) - WND_SPACING, y + (rc.bottom - rc.top) + WND_SPACING, + rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, GetDlgItem(hwnd, IDC_IB_SEPARATOR), 0, WND_SPACING, hToolBar + WND_SPACING, - w-WND_SPACING*2, 2, + w - WND_SPACING * 2, 2, SWP_NOZORDER); } @@ -269,40 +265,39 @@ void LayoutHistoryWnd(HWND hwnd, WindowData *data) GetWindowRect(data->hwndStatus, &rc); int hStatus = rc.bottom - rc.top; hDwp = DeferWindowPos(hDwp, data->hwndStatus, 0, - 0, h-hStatus, + 0, h - hStatus, w, hStatus, SWP_NOZORDER); int hSearch = 0; - if (data->wndOptions & WND_OPT_SEARCHBAR) - { + if (data->wndOptions & WND_OPT_SEARCHBAR) { GetWindowRect(data->hwndSearchText, &rc); hSearch = rc.bottom - rc.top; hDwp = DeferWindowPos(hDwp, data->hwndBtnCloseSearch, 0, - WND_SPACING, h-hSearch-hStatus-WND_SPACING, + WND_SPACING, h - hSearch - hStatus - WND_SPACING, TBTN_SIZE, hSearch, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, data->hwndSearchText, 0, - TBTN_SIZE+WND_SPACING*2, h-hSearch-hStatus-WND_SPACING, - w-WND_SPACING*4-TBTN_SIZE*3, hSearch, + TBTN_SIZE + WND_SPACING * 2, h - hSearch - hStatus - WND_SPACING, + w - WND_SPACING * 4 - TBTN_SIZE * 3, hSearch, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, data->hwndBtnFindPrev, 0, - w-WND_SPACING-TBTN_SIZE*2, h-hSearch-hStatus-WND_SPACING, + w - WND_SPACING - TBTN_SIZE * 2, h - hSearch - hStatus - WND_SPACING, TBTN_SIZE, hSearch, SWP_NOZORDER); hDwp = DeferWindowPos(hDwp, data->hwndBtnFindNext, 0, - w-WND_SPACING-TBTN_SIZE*1, h-hSearch-hStatus-WND_SPACING, + w - WND_SPACING - TBTN_SIZE * 1, h - hSearch - hStatus - WND_SPACING, TBTN_SIZE, hSearch, SWP_NOZORDER); hSearch += WND_SPACING; } hDwp = DeferWindowPos(hDwp, data->hwndLog, 0, - WND_SPACING, hToolBar+hFilterBar+WND_SPACING, - w-WND_SPACING*2, h-WND_SPACING*2-hFilterBar-hToolBar-hSearch-hStatus, + WND_SPACING, hToolBar + hFilterBar + WND_SPACING, + w - WND_SPACING * 2, h - WND_SPACING * 2 - hFilterBar - hToolBar - hSearch - hStatus, SWP_NOZORDER); EndDeferWindowPos(hDwp); -// InvalidateRect(hwnd, 0, FALSE); + // InvalidateRect(hwnd, 0, FALSE); } /* @@ -361,12 +356,12 @@ bool ExportHistoryDialog(HANDLE hContact, HWND hwndHistory) free(fn); } fclose(f); - + if (!FindNextFile(hFind, &ffd)) break; } - - + + char filename[MAX_PATH] = {0}; OPENFILENAME ofn = {0}; @@ -406,20 +401,20 @@ bool ExportHistoryDialog(HANDLE hContact, HWND hwndHistory) INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + RECT rc; + //CallSnappingWindowProc(hwnd, msg, wParam, lParam); WindowData *data = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if ((msg >= NSM_FIRST) && (msg < NSM_LAST)) - { + if ((msg >= NSM_FIRST) && (msg < NSM_LAST)) { int result = SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), msg, wParam, lParam); SetWindowLongPtr(hwnd, DWLP_MSGRESULT, result); return result; } - switch (msg) - { - case WM_INITDIALOG: + switch (msg) { + case WM_INITDIALOG: { data = new WindowData; data->hContact = (MCONTACT)lParam; @@ -453,11 +448,11 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara // filterbar SendMessage(data->hwndBtnToolbar[TBTN_FILTER], BUTTONSETASPUSHBTN, 0, 0); SendMessage(data->hwndBtnToolbar[TBTN_SEARCH], BUTTONSETASPUSHBTN, 0, 0); - + data->hwndChkDateFrom = GetDlgItem(hwnd, IDC_CHK_DATE_FROM); - data->hwndChkDateTo= GetDlgItem(hwnd, IDC_CHK_DATE_TO); + data->hwndChkDateTo = GetDlgItem(hwnd, IDC_CHK_DATE_TO); data->hwndDateFrom = GetDlgItem(hwnd, IDC_DATE_FROM); - data->hwndDateTo= GetDlgItem(hwnd, IDC_DATE_TO); + data->hwndDateTo = GetDlgItem(hwnd, IDC_DATE_TO); data->ibMessages.hwndIco = GetDlgItem(hwnd, IDC_ICO_MESSAGES); data->ibMessages.hwndTxt = GetDlgItem(hwnd, IDC_TXT_MESSAGES); @@ -510,7 +505,7 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SendMessage(data->ibTotal.hwndIcoOut, BUTTONSETASPUSHBTN, 0, 0); SendMessage(data->ibTotal.hwndIcoOut, BM_SETCHECK, BST_CHECKED, 0); data->ibTotal.hwndTxtOut = GetDlgItem(hwnd, IDC_TXT_TOTAL_OUT); - + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); data->hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_POPUPS)); @@ -532,79 +527,75 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_AUTO, data->showFlags&HIST_AUTO_FILTER ? MF_CHECKED : MF_UNCHECKED); -// CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_LOGOPTIONS_SHOWTIMETREE, -// data->showFlags&HIST_TIMETREE ? MF_CHECKED : MF_UNCHECKED); -// ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), data->showFlags&HIST_TIMETREE ? SW_SHOW : SW_HIDE); + // CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_LOGOPTIONS_SHOWTIMETREE, + // data->showFlags&HIST_TIMETREE ? MF_CHECKED : MF_UNCHECKED); + // ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), data->showFlags&HIST_TIMETREE ? SW_SHOW : SW_HIDE); - // Ask for layout + // Ask for layout PostMessage(hwnd, WM_SIZE, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_USERINFO), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_MESSAGE), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_USERMENU), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_COPY), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_LOGOPTIONS),BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_FILTER), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_USERINFO), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_MESSAGE), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_USERMENU), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_COPY), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_LOGOPTIONS), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_FILTER), BUTTONSETASFLATBTN, 0, 0); SendMessage(GetDlgItem(hwnd, IDC_DATEPOPUP), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_EXPORT), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_CLOSE), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_FINDPREV), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_FINDNEXT), BUTTONSETASFLATBTN, 0, 0); - - SendMessage(GetDlgItem(hwnd, IDC_USERINFO), BUTTONADDTOOLTIP, (WPARAM)Translate("User Info"), 0); - SendMessage(GetDlgItem(hwnd, IDC_MESSAGE), BUTTONADDTOOLTIP, (WPARAM)Translate("Send Message"), 0); - SendMessage(GetDlgItem(hwnd, IDC_USERMENU), BUTTONADDTOOLTIP, (WPARAM)Translate("User Menu"), 0); - SendMessage(GetDlgItem(hwnd, IDC_COPY), BUTTONADDTOOLTIP, (WPARAM)Translate("Copy"), 0); - SendMessage(GetDlgItem(hwnd, IDC_LOGOPTIONS),BUTTONADDTOOLTIP, (WPARAM)Translate("Options"), 0); - SendMessage(GetDlgItem(hwnd, IDC_FILTER), BUTTONADDTOOLTIP, (WPARAM)Translate("Filter"), 0); + SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_EXPORT), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_CLOSE), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_FINDPREV), BUTTONSETASFLATBTN, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_FINDNEXT), BUTTONSETASFLATBTN, 0, 0); + + SendMessage(GetDlgItem(hwnd, IDC_USERINFO), BUTTONADDTOOLTIP, (WPARAM)Translate("User Info"), 0); + SendMessage(GetDlgItem(hwnd, IDC_MESSAGE), BUTTONADDTOOLTIP, (WPARAM)Translate("Send Message"), 0); + SendMessage(GetDlgItem(hwnd, IDC_USERMENU), BUTTONADDTOOLTIP, (WPARAM)Translate("User Menu"), 0); + SendMessage(GetDlgItem(hwnd, IDC_COPY), BUTTONADDTOOLTIP, (WPARAM)Translate("Copy"), 0); + SendMessage(GetDlgItem(hwnd, IDC_LOGOPTIONS), BUTTONADDTOOLTIP, (WPARAM)Translate("Options"), 0); + SendMessage(GetDlgItem(hwnd, IDC_FILTER), BUTTONADDTOOLTIP, (WPARAM)Translate("Filter"), 0); SendMessage(GetDlgItem(hwnd, IDC_DATEPOPUP), BUTTONADDTOOLTIP, (WPARAM)Translate("Jump2Date"), 0); - SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BUTTONADDTOOLTIP, (WPARAM)Translate("Search..."), 0); - SendMessage(GetDlgItem(hwnd, IDC_EXPORT), BUTTONADDTOOLTIP, (WPARAM)Translate("Export..."), 0); - SendMessage(GetDlgItem(hwnd, IDC_CLOSE), BUTTONADDTOOLTIP, (WPARAM)Translate("Close"), 0); - SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BUTTONADDTOOLTIP, (WPARAM)Translate("Security Options"), 0); - SendMessage(GetDlgItem(hwnd, IDC_FINDPREV), BUTTONADDTOOLTIP, (WPARAM)Translate("Find Previous"), 0); - SendMessage(GetDlgItem(hwnd, IDC_FINDNEXT), BUTTONADDTOOLTIP, (WPARAM)Translate("Find Next"), 0); + SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BUTTONADDTOOLTIP, (WPARAM)Translate("Search..."), 0); + SendMessage(GetDlgItem(hwnd, IDC_EXPORT), BUTTONADDTOOLTIP, (WPARAM)Translate("Export..."), 0); + SendMessage(GetDlgItem(hwnd, IDC_CLOSE), BUTTONADDTOOLTIP, (WPARAM)Translate("Close"), 0); + SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BUTTONADDTOOLTIP, (WPARAM)Translate("Security Options"), 0); + SendMessage(GetDlgItem(hwnd, IDC_FINDPREV), BUTTONADDTOOLTIP, (WPARAM)Translate("Find Previous"), 0); + SendMessage(GetDlgItem(hwnd, IDC_FINDNEXT), BUTTONADDTOOLTIP, (WPARAM)Translate("Find Next"), 0); WindowList_Add(hNewstoryWindows, hwnd, data->hContact); - if (data->hContact && (data->hContact != INVALID_CONTACT_ID)) - { + if (data->hContact && (data->hContact != INVALID_CONTACT_ID)) { TCHAR *title = TplFormatString(TPL_TITLE, data->hContact, 0); SetWindowText(hwnd, title); free(title); - } else - if (data->hContact == INVALID_CONTACT_ID) - { - SetWindowText(hwnd, TranslateT("Newstory Search Results")); - } else - { - SetWindowText(hwnd, TranslateT("System Newstory")); } + else + if (data->hContact == INVALID_CONTACT_ID) { + SetWindowText(hwnd, TranslateT("Newstory Search Results")); + } + else { + SetWindowText(hwnd, TranslateT("System Newstory")); + } - if (data->hContact != INVALID_CONTACT_ID) - { -// ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), SW_HIDE); -// ShowWindow(GetDlgItem(hwnd, IDC_ITEMS), SW_HIDE); -// ShowWindow(GetDlgItem(hwnd, IDC_ITEMS2), SW_HIDE); -// ShowWindow(GetDlgItem(hwnd, IDC_SEARCHICON), SW_HIDE); + if (data->hContact != INVALID_CONTACT_ID) { + // ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), SW_HIDE); + // ShowWindow(GetDlgItem(hwnd, IDC_ITEMS), SW_HIDE); + // ShowWindow(GetDlgItem(hwnd, IDC_ITEMS2), SW_HIDE); + // ShowWindow(GetDlgItem(hwnd, IDC_SEARCHICON), SW_HIDE); PostMessage(GetDlgItem(hwnd, IDC_ITEMS2), WM_USER, (WPARAM)data->hContact, 0); } SendMessage(hwnd, UM_UPDATEICONS, 0, 0); SetFocus(GetDlgItem(hwnd, IDC_ITEMS2)); - RECT rc - { - (LONG)db_get_dw(data->hContact, MODULENAME, "left"), - (LONG)db_get_dw(data->hContact, MODULENAME, "top"), - (LONG)db_get_dw(data->hContact, MODULENAME, "right"), - (LONG)db_get_dw(data->hContact, MODULENAME, "bottom") - }; - if ((rc.left-rc.right) && (rc.top-rc.bottom)) - MoveWindow(hwnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); - + int left = db_get_dw(data->hContact, MODULENAME, "left"), + top = db_get_dw(data->hContact, MODULENAME, "top"), + right = db_get_dw(data->hContact, MODULENAME, "right"), + bottom = db_get_dw(data->hContact, MODULENAME, "bottom"); + + if (left - right && top - bottom) + MoveWindow(hwnd, left, top, right - left, bottom - top, TRUE); + ShowHideControls(hwnd, data); return TRUE; @@ -614,132 +605,119 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SendMessage(GetDlgItem(hwnd, IDC_CUSTOM1), msg, wParam, lParam); return TRUE;*/ - /*case WM_SETFOCUS: - SetFocus(GetDlgItem(hwnd, IDC_CUSTOM1)); - return TRUE;*/ - - case UM_UPDATEICONS: - { - SendMessage(hwnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)GetIcon(ICO_NEWSTORY)); - - SendMessage(GetDlgItem(hwnd, IDC_SEARCHICON), STM_SETICON, (WPARAM)GetIcon(ICO_SEARCH), 0); - - SendMessage(GetDlgItem(hwnd, IDC_USERINFO), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_USERINFO)); - SendMessage(GetDlgItem(hwnd, IDC_MESSAGE), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_SENDMSG)); - SendMessage(GetDlgItem(hwnd, IDC_USERMENU), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_USERMENU)); - SendMessage(GetDlgItem(hwnd, IDC_COPY), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_COPY)); - SendMessage(GetDlgItem(hwnd, IDC_LOGOPTIONS),BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_OPTIONS)); - SendMessage(GetDlgItem(hwnd, IDC_FILTER), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_FILTER)); - SendMessage(GetDlgItem(hwnd, IDC_DATEPOPUP), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_CALENDAR)); - SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_SEARCH)); - SendMessage(GetDlgItem(hwnd, IDC_EXPORT), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_EXPORT)); - SendMessage(GetDlgItem(hwnd, IDC_CLOSE), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_CLOSE)); - SendMessage(GetDlgItem(hwnd, IDC_FINDPREV), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_FINDPREV)); - SendMessage(GetDlgItem(hwnd, IDC_FINDNEXT), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_FINDNEXT)); - - SendMessage(data->ibMessages.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_SENDMSG), 0); - SendMessage(data->ibMessages.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); - SendMessage(data->ibMessages.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); - SendMessage(data->ibFiles.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_FILE), 0); - SendMessage(data->ibFiles.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); - SendMessage(data->ibFiles.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); - SendMessage(data->ibUrls.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_URL), 0); - SendMessage(data->ibUrls.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); - SendMessage(data->ibUrls.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); - SendMessage(data->ibTotal.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_UNKNOWN), 0); - SendMessage(data->ibTotal.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); - SendMessage(data->ibTotal.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); - - if (CheckPassword(data->hContact, "")) - SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_NOPASSWORD)); - else - SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_PASSWORD)); - - break; - } - - case UM_REBUILDLIST: - { -// if (data->showFlags & HIST_TIMETREE) -// ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), SW_SHOW); -// ShowWindow(GetDlgItem(hwnd, IDC_ITEMS2), SW_SHOW); -// ShowWindow(GetDlgItem(hwnd, IDC_SEARCHICON), SW_SHOW); - - return TRUE; - } - -/* - case UM_JUMP2TIME: - { - for (int i = 0; i < data->eventCount; i++) - { - ItemData *idata = (ItemData *)SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_GETITEMDATA, i, 0); - if (idata->dbe->timestamp >= wParam) + /*case WM_SETFOCUS: + SetFocus(GetDlgItem(hwnd, IDC_CUSTOM1)); + return TRUE;*/ + + case UM_UPDATEICONS: + SendMessage(hwnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)GetIcon(ICO_NEWSTORY)); + + SendMessage(GetDlgItem(hwnd, IDC_SEARCHICON), STM_SETICON, (WPARAM)GetIcon(ICO_SEARCH), 0); + + SendMessage(GetDlgItem(hwnd, IDC_USERINFO), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_USERINFO)); + SendMessage(GetDlgItem(hwnd, IDC_MESSAGE), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_SENDMSG)); + SendMessage(GetDlgItem(hwnd, IDC_USERMENU), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_USERMENU)); + SendMessage(GetDlgItem(hwnd, IDC_COPY), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_COPY)); + SendMessage(GetDlgItem(hwnd, IDC_LOGOPTIONS), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_OPTIONS)); + SendMessage(GetDlgItem(hwnd, IDC_FILTER), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_FILTER)); + SendMessage(GetDlgItem(hwnd, IDC_DATEPOPUP), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_CALENDAR)); + SendMessage(GetDlgItem(hwnd, IDC_SEARCH), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_SEARCH)); + SendMessage(GetDlgItem(hwnd, IDC_EXPORT), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_EXPORT)); + SendMessage(GetDlgItem(hwnd, IDC_CLOSE), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_CLOSE)); + SendMessage(GetDlgItem(hwnd, IDC_FINDPREV), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_FINDPREV)); + SendMessage(GetDlgItem(hwnd, IDC_FINDNEXT), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_FINDNEXT)); + + SendMessage(data->ibMessages.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_SENDMSG), 0); + SendMessage(data->ibMessages.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); + SendMessage(data->ibMessages.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); + SendMessage(data->ibFiles.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_FILE), 0); + SendMessage(data->ibFiles.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); + SendMessage(data->ibFiles.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); + SendMessage(data->ibUrls.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_URL), 0); + SendMessage(data->ibUrls.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); + SendMessage(data->ibUrls.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); + SendMessage(data->ibTotal.hwndIco, STM_SETICON, (LPARAM)GetIcon(ICO_UNKNOWN), 0); + SendMessage(data->ibTotal.hwndIcoIn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGIN)); + SendMessage(data->ibTotal.hwndIcoOut, BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_MSGOUT)); + + if (CheckPassword(data->hContact, "")) + SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_NOPASSWORD)); + else + SendMessage(GetDlgItem(hwnd, IDC_SECURITY), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_PASSWORD)); + + break; + + case UM_REBUILDLIST: + // if (data->showFlags & HIST_TIMETREE) + // ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), SW_SHOW); + // ShowWindow(GetDlgItem(hwnd, IDC_ITEMS2), SW_SHOW); + // ShowWindow(GetDlgItem(hwnd, IDC_SEARCHICON), SW_SHOW); + + return TRUE; + + /* + case UM_JUMP2TIME: { - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, i, 0); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, i, 0); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount)); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(i,i)); - break; + for (int i = 0; i < data->eventCount; i++) + { + ItemData *idata = (ItemData *)SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_GETITEMDATA, i, 0); + if (idata->dbe->timestamp >= wParam) + { + SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, i, 0); + SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, i, 0); + SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount)); + SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(i,i)); + break; + } + } + return TRUE; } - } - return TRUE; - } -*/ - case WM_MEASUREITEM: - { - LPMEASUREITEMSTRUCT lpmis; - lpmis = (LPMEASUREITEMSTRUCT) lParam; + */ - if (lpmis->CtlType == ODT_MENU) - return Menu_MeasureItem(lParam); + case WM_MEASUREITEM: + LPMEASUREITEMSTRUCT lpmis; + lpmis = (LPMEASUREITEMSTRUCT)lParam; - lpmis->itemHeight = 25; - return TRUE; - } + if (lpmis->CtlType == ODT_MENU) + return Menu_MeasureItem(lParam); - case WM_SIZE: - { - LayoutHistoryWnd(hwnd, data); - return TRUE; - } + lpmis->itemHeight = 25; + return TRUE; - case WM_CHARTOITEM: - { - if (!((GetKeyState(VK_CONTROL)&0x80) || (GetKeyState(VK_MENU)&0x80))) - { - TCHAR s[] = { LOWORD(wParam), 0 }; - SetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), s); - SendMessage(GetDlgItem(hwnd, IDC_SEARCHTEXT), EM_SETSEL, 1, 1); - SetFocus(GetDlgItem(hwnd, IDC_SEARCHTEXT)); - } - return -1; + case WM_SIZE: + LayoutHistoryWnd(hwnd, data); + return TRUE; + + case WM_CHARTOITEM: + if (!((GetKeyState(VK_CONTROL) & 0x80) || (GetKeyState(VK_MENU) & 0x80))) { + TCHAR s[] = { LOWORD(wParam), 0 }; + SetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), s); + SendMessage(GetDlgItem(hwnd, IDC_SEARCHTEXT), EM_SETSEL, 1, 1); + SetFocus(GetDlgItem(hwnd, IDC_SEARCHTEXT)); } + return -1; - case WM_CLOSE: - { - WindowList_Remove(hNewstoryWindows, hwnd); + case WM_CLOSE: + WindowList_Remove(hNewstoryWindows, hwnd); - db_set_dw(data->hContact, MODULENAME, "showFlags", data->showFlags); - RECT rc; - GetWindowRect(hwnd, &rc); - db_set_dw(data->hContact, MODULENAME, "left", rc.left); - db_set_dw(data->hContact, MODULENAME, "top", rc.top); - db_set_dw(data->hContact, MODULENAME, "right", rc.right); - db_set_dw(data->hContact, MODULENAME, "bottom", rc.bottom); + db_set_dw(data->hContact, MODULENAME, "showFlags", data->showFlags); + GetWindowRect(hwnd, &rc); + db_set_dw(data->hContact, MODULENAME, "left", rc.left); + db_set_dw(data->hContact, MODULENAME, "top", rc.top); + db_set_dw(data->hContact, MODULENAME, "right", rc.right); + db_set_dw(data->hContact, MODULENAME, "bottom", rc.bottom); -// CLCombo_Cleanup(GetDlgItem(hwnd, IDC_USERLIST)); + // CLCombo_Cleanup(GetDlgItem(hwnd, IDC_USERLIST)); - DestroyMenu(data->hMenu); - delete data; - DestroyWindow(hwnd); - return TRUE; - } + DestroyMenu(data->hMenu); + delete data; + DestroyWindow(hwnd); + return TRUE; - case WM_DRAWITEM: + case WM_DRAWITEM: { LPDRAWITEMSTRUCT lpdis; - lpdis = (LPDRAWITEMSTRUCT) lParam; + lpdis = (LPDRAWITEMSTRUCT)lParam; if (lpdis->CtlType == ODT_MENU) return Menu_DrawItem(lParam); @@ -747,32 +725,29 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (lpdis->itemID == -1) return FALSE; - return TRUE; + return TRUE; } - case WM_NOTIFY: + case WM_NOTIFY: { LPNMHDR hdr = (LPNMHDR)lParam; - switch (hdr->idFrom) - { - case IDC_TIMETREE: + switch (hdr->idFrom) { + case IDC_TIMETREE: { - switch (hdr->code) - { - case TVN_SELCHANGED: + switch (hdr->code) { + case TVN_SELCHANGED: { - if (data->disableTimeTreeChange) - { + if (data->disableTimeTreeChange) { data->disableTimeTreeChange = false; - } else - { -// LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; -// int id = pnmtv->itemNew.lParam; -// SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, id, 0); -// SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_ITEMS, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwnd, IDC_ITEMS)); -// SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, id, 0); -// SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount)); -// SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(id,id)); + } + else { + // LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; + // int id = pnmtv->itemNew.lParam; + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, id, 0); + // SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_ITEMS, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwnd, IDC_ITEMS)); + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, id, 0); + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount)); + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(id,id)); } break; } @@ -780,267 +755,232 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; } } - return TRUE; } + return TRUE; - case WM_COMMAND: - { - //if (Menu_ProcessCommand(MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM) data->hContact)) - // return TRUE; - switch(LOWORD(wParam)) + case WM_COMMAND: + // if (Menu_ProcessCommand(MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM) data->hContact)) + // return TRUE; + + switch (LOWORD(wParam)) { + case IDCANCEL: + case IDC_CLOSE: + SendMessage(hwnd, WM_CLOSE, 0, 0); + break; + + case IDC_MESSAGE: + CallService(MS_MSG_SENDMESSAGE, (WPARAM)data->hContact, 0); + break; + + case IDC_USERINFO: + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)data->hContact, 0); + break; + + case IDC_DATEPOPUP: { - case IDCANCEL: - case IDC_CLOSE: - SendMessage(hwnd, WM_CLOSE, 0, 0); - break; + GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); + time_t tm_jump = CalendarTool_Show(hwnd, rc.left, rc.bottom); + if (tm_jump) PostMessage(hwnd, UM_JUMP2TIME, tm_jump, 0); + break; + } - case IDC_MESSAGE: - CallService(MS_MSG_SENDMESSAGE, (WPARAM)data->hContact, 0); - break; + case IDC_USERMENU: + { + HMENU hMenu = Menu_BuildContactMenu(data->hContact); + GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); + TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwnd, NULL); + DestroyMenu(hMenu); + break; + } - case IDC_USERINFO: - CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)data->hContact, 0); + case IDC_LOGOPTIONS: + { + GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); + // DWORD itemID = 0; + switch (TrackPopupMenu(GetSubMenu(data->hMenu, 2), TPM_RETURNCMD, rc.left, rc.bottom, 0, hwnd, NULL)) { + // case ID_LOGOPTIONS_SHOWTIMETREE: + // { + // data->showFlags = toggleBit(data->showFlags, HIST_TIMETREE); + // CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_LOGOPTIONS_SHOWTIMETREE, + // data->showFlags&HIST_TIMETREE ? MF_CHECKED : MF_UNCHECKED); + // ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), data->showFlags&HIST_TIMETREE ? SW_SHOW : SW_HIDE); + // break; + // } + + case ID_LOGOPTIONS_OPTIONS: + g_plugin.openOptions(nullptr, L"Newstory", L"General"); break; - case IDC_DATEPOPUP: - { - RECT rc; - GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); - time_t tm_jump = CalendarTool_Show(hwnd, rc.left, rc.bottom); - if (tm_jump) PostMessage(hwnd, UM_JUMP2TIME, tm_jump, 0); + case ID_LOGOPTIONS_TEMPLATES: + g_plugin.openOptions(nullptr, L"Newstory", L"Templates"); break; - } - case IDC_USERMENU: - { - RECT rc; - HMENU hMenu = Menu_BuildContactMenu(data->hContact); - GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); - TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwnd, NULL); - DestroyMenu(hMenu); + case ID_LOGOPTIONS_PASSWORDS: + g_plugin.openOptions(nullptr, L"Newstory", L"Passwords (not ready yet)"); break; } + PostMessage(hwnd, WM_SIZE, 0, 0); + break; + } - case IDC_LOGOPTIONS: - { - RECT rc; - GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); + case IDC_SEARCH: + if (data->wndOptions & WND_OPT_SEARCHBAR) + data->wndOptions &= ~WND_OPT_SEARCHBAR; + else + data->wndOptions |= WND_OPT_SEARCHBAR; + + ShowHideControls(hwnd, data); + LayoutHistoryWnd(hwnd, data); + break; + + case IDC_FILTER: + if (data->wndOptions & WND_OPT_FILTERBAR) + data->wndOptions &= ~WND_OPT_FILTERBAR; + else + data->wndOptions |= WND_OPT_FILTERBAR; + + ShowHideControls(hwnd, data); + LayoutHistoryWnd(hwnd, data); + break; + + /* + GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); // DWORD itemID = 0; - switch (TrackPopupMenu(GetSubMenu(data->hMenu, 2), TPM_RETURNCMD, rc.left, rc.bottom, 0, hwnd, NULL)) - { -// case ID_LOGOPTIONS_SHOWTIMETREE: -// { -// data->showFlags = toggleBit(data->showFlags, HIST_TIMETREE); -// CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_LOGOPTIONS_SHOWTIMETREE, -// data->showFlags&HIST_TIMETREE ? MF_CHECKED : MF_UNCHECKED); -// ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), data->showFlags&HIST_TIMETREE ? SW_SHOW : SW_HIDE); -// break; -// } - - case ID_LOGOPTIONS_OPTIONS: - { - OptShowPage = 0; - g_plugin.openOptions(nullptr, L"Newstory"); - break; - } - case ID_LOGOPTIONS_TEMPLATES: - { - OptShowPage = 1; - g_plugin.openOptions(nullptr, L"Newstory"); - break; - } - case ID_LOGOPTIONS_PASSWORDS: - { - OptShowPage = 2; - g_plugin.openOptions(nullptr, L"Newstory"); - break; - } - } - PostMessage(hwnd, WM_SIZE, 0, 0); + bool doFilter = true; + switch (TrackPopupMenu(GetSubMenu(data->hMenu, 1), TPM_RETURNCMD, rc.left, rc.bottom, 0, hwnd, NULL)) + { + case ID_FILTER_INCOMING: + { + data->showFlags = toggleBit(data->showFlags, HIST_SHOW_IN); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_INCOMING, + data->showFlags&HIST_SHOW_IN ? MF_CHECKED : MF_UNCHECKED); break; } - - case IDC_SEARCH: + case ID_FILTER_OUTGOING: { - if (data->wndOptions & WND_OPT_SEARCHBAR) - { - data->wndOptions &= ~WND_OPT_SEARCHBAR; - } else - { - data->wndOptions |= WND_OPT_SEARCHBAR; - } - ShowHideControls(hwnd, data); - LayoutHistoryWnd(hwnd, data); + data->showFlags = toggleBit(data->showFlags, HIST_SHOW_OUT); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OUTGOING, + data->showFlags&HIST_SHOW_OUT ? MF_CHECKED : MF_UNCHECKED); break; } - - case IDC_FILTER: + case ID_FILTER_MESSAGES: { - if (data->wndOptions & WND_OPT_FILTERBAR) - { - data->wndOptions &= ~WND_OPT_FILTERBAR; - } else - { - data->wndOptions |= WND_OPT_FILTERBAR; - } - ShowHideControls(hwnd, data); - LayoutHistoryWnd(hwnd, data); + data->showFlags = toggleBit(data->showFlags, HIST_SHOW_MSGS); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_MESSAGES, + data->showFlags&HIST_SHOW_MSGS ? MF_CHECKED : MF_UNCHECKED); break; - - /*RECT rc; - GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); -// DWORD itemID = 0; - bool doFilter = true; - switch (TrackPopupMenu(GetSubMenu(data->hMenu, 1), TPM_RETURNCMD, rc.left, rc.bottom, 0, hwnd, NULL)) - { - case ID_FILTER_INCOMING: - { - data->showFlags = toggleBit(data->showFlags, HIST_SHOW_IN); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_INCOMING, - data->showFlags&HIST_SHOW_IN ? MF_CHECKED : MF_UNCHECKED); - break; - } - case ID_FILTER_OUTGOING: - { - data->showFlags = toggleBit(data->showFlags, HIST_SHOW_OUT); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OUTGOING, - data->showFlags&HIST_SHOW_OUT ? MF_CHECKED : MF_UNCHECKED); - break; - } - case ID_FILTER_MESSAGES: - { - data->showFlags = toggleBit(data->showFlags, HIST_SHOW_MSGS); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_MESSAGES, - data->showFlags&HIST_SHOW_MSGS ? MF_CHECKED : MF_UNCHECKED); - break; - } - case ID_FILTER_FILES: - { - data->showFlags = toggleBit(data->showFlags, HIST_SHOW_FILES); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_FILES, - data->showFlags&HIST_SHOW_FILES ? MF_CHECKED : MF_UNCHECKED); - break; - } - case ID_FILTER_URLS: - { - data->showFlags = toggleBit(data->showFlags, HIST_SHOW_URLS); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_URLS, - data->showFlags&HIST_SHOW_URLS ? MF_CHECKED : MF_UNCHECKED); - break; - } - case ID_FILTER_STATUS: - { - data->showFlags = toggleBit(data->showFlags, HIST_SHOW_STATUS); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_STATUS, - data->showFlags&HIST_SHOW_STATUS ? MF_CHECKED : MF_UNCHECKED); - break; - } - case ID_FILTER_OTHER: - { - data->showFlags = toggleBit(data->showFlags, HIST_SHOW_OTHER); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OTHER, - data->showFlags&HIST_SHOW_OTHER ? MF_CHECKED : MF_UNCHECKED); - break; - } - case ID_FILTER_AUTO: - { - data->showFlags = toggleBit(data->showFlags, HIST_AUTO_FILTER); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_AUTO, - data->showFlags&HIST_AUTO_FILTER ? MF_CHECKED : MF_UNCHECKED); - break; - } - default: - { - doFilter = false; - break; - } - } - if (doFilter) - PostMessage(hwnd, UM_REBUILDLIST, 0, 0); - break;*/ } - - case IDC_SECURITY: + case ID_FILTER_FILES: { - ChangePassword(hwnd, data->hContact); - PostMessage(hwnd, UM_UPDATEICONS, 0, 0); + data->showFlags = toggleBit(data->showFlags, HIST_SHOW_FILES); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_FILES, + data->showFlags&HIST_SHOW_FILES ? MF_CHECKED : MF_UNCHECKED); break; } - - case IDC_EXPORT: + case ID_FILTER_URLS: { -// ExportHistoryDialog(data->hContact, hwnd); -// DialogBox(hInst, MAKEINTRESOURCE(IDD_EXPORT), hwnd, ExportWndProc); + data->showFlags = toggleBit(data->showFlags, HIST_SHOW_URLS); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_URLS, + data->showFlags&HIST_SHOW_URLS ? MF_CHECKED : MF_UNCHECKED); break; } - - case IDC_SEARCHTEXT: - if ((data->showFlags&HIST_AUTO_FILTER) && (HIWORD(wParam) == EN_CHANGE)) - PostMessage(hwnd, UM_REBUILDLIST, 0, 0); - break; -/* - case IDC_EXPORT: + case ID_FILTER_STATUS: { - RECT rc; - GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); - TrackPopupMenu(GetSubMenu(data->hMenu, 0), TPM_RETURNCMD, rc.left, rc.bottom, 0, hwnd, NULL); + data->showFlags = toggleBit(data->showFlags, HIST_SHOW_STATUS); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_STATUS, + data->showFlags&HIST_SHOW_STATUS ? MF_CHECKED : MF_UNCHECKED); break; } -*/ -/* - case IDC_SEARCH: + case ID_FILTER_OTHER: { - int id = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SEARCH), 0, SearchDlgProc, (LPARAM)GetDlgItem(hwnd, IDC_ITEMS)); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, id, 0); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, id, 0); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount)); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(id,id)); + data->showFlags = toggleBit(data->showFlags, HIST_SHOW_OTHER); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OTHER, + data->showFlags&HIST_SHOW_OTHER ? MF_CHECKED : MF_UNCHECKED); break; } -*/ - case IDC_FINDPREV: + case ID_FILTER_AUTO: { - int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT))+1; - TCHAR *buf = new TCHAR[bufSize]; - GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT))+1); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDPREV, (WPARAM)buf, 0); - delete [] buf; + data->showFlags = toggleBit(data->showFlags, HIST_AUTO_FILTER); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_AUTO, + data->showFlags&HIST_AUTO_FILTER ? MF_CHECKED : MF_UNCHECKED); break; } - - case IDOK: - case IDC_FINDNEXT: + default: { - int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT))+1; - TCHAR *buf = new TCHAR[bufSize]; - GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT))+1); - SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDNEXT, (WPARAM)buf, 0); - delete [] buf; + doFilter = false; break; } + } + if (doFilter) + PostMessage(hwnd, UM_REBUILDLIST, 0, 0); + break;*/ + + case IDC_SECURITY: + ChangePassword(hwnd, data->hContact); + PostMessage(hwnd, UM_UPDATEICONS, 0, 0); + break; - case IDC_COPY: - { - SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_COPY, 0, 0); - } - break; + case IDC_EXPORT: + // ExportHistoryDialog(data->hContact, hwnd); + // DialogBox(hInst, MAKEINTRESOURCE(IDD_EXPORT), hwnd, ExportWndProc); + break; + + case IDC_SEARCHTEXT: + if ((data->showFlags&HIST_AUTO_FILTER) && (HIWORD(wParam) == EN_CHANGE)) + PostMessage(hwnd, UM_REBUILDLIST, 0, 0); + break; + + // case IDC_EXPORT: + // GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc); + // TrackPopupMenu(GetSubMenu(data->hMenu, 0), TPM_RETURNCMD, rc.left, rc.bottom, 0, hwnd, NULL); + // break; + + // case IDC_SEARCH: + // int id = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SEARCH), 0, SearchDlgProc, (LPARAM)GetDlgItem(hwnd, IDC_ITEMS)); + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, id, 0); + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, id, 0); + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount)); + // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(id,id)); + // break; + + case IDC_FINDPREV: + { + int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1; + TCHAR *buf = new TCHAR[bufSize]; + GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1); + SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDPREV, (WPARAM)buf, 0); + delete[] buf; } - return TRUE; + break; + + case IDOK: + case IDC_FINDNEXT: + { + int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1; + TCHAR *buf = new TCHAR[bufSize]; + GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1); + SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDNEXT, (WPARAM)buf, 0); + delete[] buf; + } + break; + + case IDC_COPY: + SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_COPY, 0, 0); + break; } + return TRUE; } - return FALSE; //DefWindowProc(hwnd, msg, wParam, lParam); + return FALSE; } INT_PTR svcShowNewstory(WPARAM wParam, LPARAM) { HWND hwnd = (HWND)WindowList_Find(hNewstoryWindows, (MCONTACT)wParam); - if (hwnd && IsWindow(hwnd)) - { - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + if (hwnd && IsWindow(hwnd)) { + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetFocus(hwnd); - } else - if (AskPassword((MCONTACT)wParam)) - { + } + else if (AskPassword((MCONTACT)wParam)) { HWND hwnd2 = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_HISTORY), 0, HistoryDlgProc, wParam); ShowWindow(hwnd2, SW_SHOWNORMAL); } @@ -1050,13 +990,11 @@ INT_PTR svcShowNewstory(WPARAM wParam, LPARAM) INT_PTR svcShowSystemNewstory(WPARAM, LPARAM) { HWND hwnd = (HWND)WindowList_Find(hNewstoryWindows, 0); - if (hwnd && IsWindow(hwnd)) - { - SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); + if (hwnd && IsWindow(hwnd)) { + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetFocus(hwnd); - } else - if (AskPassword(0)) - { + } + else if (AskPassword(0)) { HWND hwnd2 = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_HISTORY), 0, HistoryDlgProc, 0); ShowWindow(hwnd2, SW_SHOWNORMAL); } diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 38d16de58e..34b8113e64 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -6,8 +6,7 @@ bool HistoryArray::ItemData::load(EventLoadMode mode) if (mode == ELM_NOTHING) return true; - if ((mode == ELM_INFO) && !dbeOk) - { + if ((mode == ELM_INFO) && !dbeOk) { dbeOk = true; dbe.cbBlob = 0; dbe.pBlob = 0; @@ -15,57 +14,52 @@ bool HistoryArray::ItemData::load(EventLoadMode mode) return true; } - if ((mode == ELM_DATA) && (!dbeOk || !dbe.cbBlob)) - { + if ((mode == ELM_DATA) && (!dbeOk || !dbe.cbBlob)) { dbeOk = true; dbe.cbBlob = db_event_getBlobSize(hEvent); - dbe.pBlob = (PBYTE)calloc(dbe.cbBlob+1, 1); + dbe.pBlob = (PBYTE)calloc(dbe.cbBlob + 1, 1); db_event_get(hEvent, &dbe); int aLength = 0; atext = 0; wtext = 0; - switch (dbe.eventType) - { - case EVENTTYPE_STATUSCHANGE: - case EVENTTYPE_MESSAGE: + switch (dbe.eventType) { + case EVENTTYPE_STATUSCHANGE: + case EVENTTYPE_MESSAGE: { atext = (char *)dbe.pBlob; atext_del = false; aLength = lstrlenA(atext); - if (dbe.cbBlob > (DWORD)aLength + 1) - { + if (dbe.cbBlob > (DWORD)aLength + 1) { wtext = (WCHAR *)(dbe.pBlob + aLength + 1); wtext_del = false; } break; } - case EVENTTYPE_AUTHREQUEST: + case EVENTTYPE_AUTHREQUEST: { atext = new char[512]; atext_del = true; - if ((dbe.cbBlob>8) && *(dbe.pBlob+8)) - { + if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { mir_snprintf(atext, 512, ("%s requested authorization"), dbe.pBlob + 8); - } else - { + } + else { mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD*)(dbe.pBlob)); } aLength = lstrlenA(atext); break; } - case EVENTTYPE_ADDED: + case EVENTTYPE_ADDED: { atext = new char[512]; atext_del = true; - if ((dbe.cbBlob>8) && *(dbe.pBlob+8)) - { + if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { mir_snprintf(atext, 512, ("%s added you to the contact list"), dbe.pBlob + 8); - } else - { + } + else { mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD*)(dbe.pBlob)); } aLength = lstrlenA(atext); @@ -73,29 +67,28 @@ bool HistoryArray::ItemData::load(EventLoadMode mode) } } - if (atext && !wtext) - { + if (atext && !wtext) { #ifdef UNICODE - int bufSize = MultiByteToWideChar(CP_ACP, 0, atext, aLength+1, 0, 0); - wtext = new WCHAR[bufSize+1]; - MultiByteToWideChar(CP_ACP, 0, atext, aLength+1, wtext, bufSize); - wtext_del = true; + int bufSize = MultiByteToWideChar(CP_ACP, 0, atext, aLength + 1, 0, 0); + wtext = new WCHAR[bufSize + 1]; + MultiByteToWideChar(CP_ACP, 0, atext, aLength + 1, wtext, bufSize); + wtext_del = true; #else - this->wtext = 0; - wtext_del = false; - #endif - } else - if (!atext && wtext) - { - // strange situation, really :) I'll fix this later - } else - if (!atext && !wtext) - { - atext = ""; - atext_del = false; - wtext = L""; + this->wtext = 0; wtext_del = false; + #endif } + else + if (!atext && wtext) { + // strange situation, really :) I'll fix this later + } + else + if (!atext && !wtext) { + atext = ""; + atext_del = false; + wtext = L""; + wtext_del = false; + } return true; } @@ -105,13 +98,12 @@ bool HistoryArray::ItemData::load(EventLoadMode mode) HistoryArray::ItemData::~ItemData() { - if (dbeOk && dbe.pBlob) - { + if (dbeOk && dbe.pBlob) { free(dbe.pBlob); dbe.pBlob = 0; } - if (wtext && wtext_del) delete [] wtext; - if (atext && atext_del) delete [] atext; + if (wtext && wtext_del) delete[] wtext; + if (atext && atext_del) delete[] atext; if (data) MTextDestroy(data); } @@ -138,11 +130,10 @@ bool HistoryArray::allocateBlock(int count) newBlock->prev = tail; newBlock->next = 0; - if (tail) - { + if (tail) { tail->next = newBlock; - } else - { + } + else { head = newBlock; } tail = newBlock; @@ -152,12 +143,11 @@ bool HistoryArray::allocateBlock(int count) void HistoryArray::clear() { - while (head) - { + while (head) { ItemBlock *next = head->next; -// for (int i = 0; i < head->count; ++i) -// destroyEvent(head->items[i]); - delete [] head->items; + // for (int i = 0; i < head->count; ++i) + // destroyEvent(head->items[i]); + delete[] head->items; head = next; } @@ -173,16 +163,13 @@ bool HistoryArray::addHistory(MCONTACT hContact, EventLoadMode) int i = 0; MEVENT hEvent = db_event_first(hContact); - while (hEvent) - { + while (hEvent) { tail->items[i].hContact = hContact; tail->items[i].hEvent = hEvent; ++i; hEvent = db_event_next(hEvent, 0); } -// char buf[666]; - return true; } @@ -218,15 +205,12 @@ HistoryArray::ItemData *HistoryArray::get(int id, EventLoadMode mode) caching = false; if (caching) EnterCriticalSection(&csItems); int offset = 0; - for (ItemBlock *p = head; p; p = p->next) - { - if (id < offset + p->count) - { + for (ItemBlock *p = head; p; p = p->next) { + if (id < offset + p->count) { if (mode != ELM_NOTHING) p->items[id - offset].load(mode); - if (caching) - { + if (caching) { if (caching_complete) caching = false; LeaveCriticalSection(&csItems); } @@ -234,8 +218,7 @@ HistoryArray::ItemData *HistoryArray::get(int id, EventLoadMode mode) } offset += p->count; } - if (caching) - { + if (caching) { if (caching_complete) caching = false; LeaveCriticalSection(&csItems); } @@ -249,4 +232,4 @@ void HistoryArray::CacheThreadFunc(void *arg) HistoryArray *_this = (HistoryArray *)arg; _this->caching_complete = true; _endthread(); -}
\ No newline at end of file +} diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 640548e84d..bf688aefdb 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -12,19 +12,19 @@ enum { HIF_SELECTED = 0x01, - FILTER_TIME = 0x01, - FILTER_TYPE = 0x02, + FILTER_TIME = 0x01, + FILTER_TYPE = 0x02, FILTER_DIRECTION = 0x04, - FILTER_TEXT = 0x08, - FILTER_UNICODE = 0x10, - - FTYPE_MESSAGE = 0x01, - FTYPE_FILE = 0x02, - FTYPE_URL = 0x04, - FTYPE_STATUS = 0x08, - FTYPE_OTHER = 0x10, - FTYPE_INCOMING = 0x20, - FTYPE_OUTGOING = 0x40 + FILTER_TEXT = 0x08, + FILTER_UNICODE = 0x10, + + FTYPE_MESSAGE = 0x01, + FTYPE_FILE = 0x02, + FTYPE_URL = 0x04, + FTYPE_STATUS = 0x08, + FTYPE_OTHER = 0x10, + FTYPE_INCOMING = 0x20, + FTYPE_OUTGOING = 0x40 }; class HistoryArray @@ -46,7 +46,7 @@ public: HANDLE data; - ItemData(): flags(0), hContact(0), hEvent(0), atext(0), wtext(0), atext_del(false), wtext_del(false), data(0), dbeOk(false) {} + ItemData() : flags(0), hContact(0), hEvent(0), atext(0), wtext(0), atext_del(false), wtext_del(false), data(0), dbeOk(false) {} ~ItemData(); bool load(EventLoadMode mode); inline bool loadInline(EventLoadMode mode) @@ -59,9 +59,9 @@ public: { loadInline(ELM_DATA); #ifdef UNICODE - return wtext; + return wtext; #else - return atext; + return atext; #endif } inline char *getBuf() @@ -88,13 +88,13 @@ public: public: enum { - INCOMING = 0x001, - OUTGOING = 0x002, - MESSAGES = 0x004, - FILES = 0x008, - URLS = 0x010, - STATUS = 0x020, - OTHER = 0x040, + INCOMING = 0x001, + OUTGOING = 0x002, + MESSAGES = 0x004, + FILES = 0x008, + URLS = 0x010, + STATUS = 0x020, + OTHER = 0x040, EVENTTEXT = 0x080, EVENTONLY = 0x100, }; @@ -102,7 +102,7 @@ public: { refCount = new int(0); flags = aFlags; - text = new TCHAR[lstrlen(aText)+1]; + text = new TCHAR[lstrlen(aText) + 1]; lstrcpy(text, aText); } Filter(const Filter &other) @@ -121,51 +121,46 @@ public: } ~Filter() { - if (!--*refCount) - { + if (!--*refCount) { delete refCount; - if (text) delete [] text; + if (text) delete[] text; } } inline bool check(ItemData *item) { if (!item) return false; - if (!(flags & EVENTONLY)) - { - if (item->dbe.flags & DBEF_SENT) - { + if (!(flags & EVENTONLY)) { + if (item->dbe.flags & DBEF_SENT) { if (!(flags & OUTGOING)) return false; - } else - { + } + else { if (!(flags & INCOMING)) return false; } - switch (item->dbe.eventType) - { - case EVENTTYPE_MESSAGE: - if (!(flags & MESSAGES)) - return false; - break; - case EVENTTYPE_FILE: - if (!(flags & FILES)) - return false; - break; - case EVENTTYPE_URL: - if (!(flags & URLS)) - return false; - break; - case EVENTTYPE_STATUSCHANGE: - if (!(flags & STATUS)) - return false; - break; - default: - if (!(flags & OTHER)) - return false; + switch (item->dbe.eventType) { + case EVENTTYPE_MESSAGE: + if (!(flags & MESSAGES)) + return false; + break; + case EVENTTYPE_FILE: + if (!(flags & FILES)) + return false; + break; + case EVENTTYPE_URL: + if (!(flags & URLS)) + return false; + break; + case EVENTTYPE_STATUSCHANGE: + if (!(flags & STATUS)) + return false; + break; + default: + if (!(flags & OTHER)) + return false; } } - if (flags & (EVENTTEXT|EVENTONLY)) - { + if (flags & (EVENTTEXT | EVENTONLY)) { item->loadInline(ELM_DATA); return CheckFilter(item->getTBuf(), text); } @@ -197,7 +192,7 @@ public: bool addHistory(MCONTACT hContact, EventLoadMode mode = ELM_NOTHING); bool addEvent(MCONTACT hContact, MEVENT hEvent, EventLoadMode mode = ELM_NOTHING); -// bool preloadEvents(int count = 10); + // bool preloadEvents(int count = 10); ItemData *get(int id, EventLoadMode mode = ELM_NOTHING); ItemData *operator[] (int id) { return get(id, ELM_DATA); } @@ -206,7 +201,7 @@ public: int FindRel(int id, int dir, Filter filter) { int count = getCount(); - for (int i = id+dir; (i >= 0) && (i < count); i += dir) + for (int i = id + dir; (i >= 0) && (i < count); i += dir) if (filter.check(get(i))) return i; return -1; diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index e0e82d0501..181d1db10d 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -6,8 +6,8 @@ HANDLE htuLog = 0; void InitNewstoryControl() { - htuLog = MTextRegister("Newstory", MTEXT_FANCY_DEFAULT|MTEXT_SYSTEM_HICONS); - WNDCLASS wndclass = {0}; + htuLog = MTextRegister("Newstory", MTEXT_FANCY_DEFAULT | MTEXT_SYSTEM_HICONS); + WNDCLASS wndclass = { 0 }; wndclass.style = /*CS_HREDRAW | CS_VREDRAW | */CS_DBLCLKS | CS_GLOBALCLASS; wndclass.lpfnWndProc = NewstoryListWndProc; wndclass.cbClsExtra = 0; @@ -63,37 +63,34 @@ static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width static WNDPROC OldEditWndProc; static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) - { + switch (msg) { case WM_KEYDOWN: - { - switch (wParam) { - case VK_ESCAPE: - { - EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0)); - return 0; - } + switch (wParam) { + case VK_ESCAPE: + { + EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0)); + return 0; + } + } + break; } - break; - } case WM_GETDLGCODE: - { - if (lParam) { - MSG *msg2 = (MSG *)lParam; - if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB) - return 0; - if (msg2->message == WM_CHAR && msg2->wParam == '\t') - return 0; + if (lParam) { + MSG *msg2 = (MSG *)lParam; + if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB) + return 0; + if (msg2->message == WM_CHAR && msg2->wParam == '\t') + return 0; + } + return DLGC_WANTMESSAGE; } - return DLGC_WANTMESSAGE; - } -// case WM_KILLFOCUS: -// { -// EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0)); -// return 0; -// } + // case WM_KILLFOCUS: + // { + // EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0)); + // return 0; + // } } return CallWindowProc(OldEditWndProc, hwnd, msg, wParam, lParam); } @@ -104,9 +101,8 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM { NewstoryListData *data = (NewstoryListData *)GetWindowLongPtr(hwnd, 0); - switch (msg) - { - case WM_CREATE: + switch (msg) { + case WM_CREATE: { data = new NewstoryListData; data->scrollTopItem = 0; @@ -120,7 +116,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; } - case WM_USER: + case WM_USER: { data->items.addHistory((MCONTACT)wParam); RecalcScrollBar(hwnd, data); @@ -131,17 +127,16 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM } // History list control messages - case NSM_GETCOUNT: + case NSM_GETCOUNT: { - return data->items.getCount(); + return data->items.getCount(); } - case NSM_SELECTITEMS: + case NSM_SELECTITEMS: { - int start = min(data->items.getCount()-1, max(0, wParam)); - int end = min(data->items.getCount()-1, max(0, lParam)); - if (start > end) - { + int start = min(data->items.getCount() - 1, max(0, wParam)); + int end = min(data->items.getCount() - 1, max(0, lParam)); + if (start > end) { start ^= end; end ^= start; start ^= end; @@ -152,23 +147,20 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return 0; } - case NSM_TOGGLEITEMS: + case NSM_TOGGLEITEMS: { - int start = min(data->items.getCount()-1, max(0, wParam)); - int end = min(data->items.getCount()-1, max(0, lParam)); - if (start > end) - { + int start = min(data->items.getCount() - 1, max(0, wParam)); + int end = min(data->items.getCount() - 1, max(0, lParam)); + if (start > end) { start ^= end; end ^= start; start ^= end; } - for (int i = start; i <= end; ++i) - { - if (data->items.get(i, ELM_NOTHING)->flags & HIF_SELECTED) - { + for (int i = start; i <= end; ++i) { + if (data->items.get(i, ELM_NOTHING)->flags & HIF_SELECTED) { data->items.get(i, ELM_NOTHING)->flags &= ~HIF_SELECTED; - } else - { + } + else { data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; } } @@ -176,24 +168,21 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return 0; } - case NSM_SELECTITEMS2: + case NSM_SELECTITEMS2: { - int start = min(data->items.getCount()-1, max(0, wParam)); - int end = min(data->items.getCount()-1, max(0, lParam)); - if (start > end) - { + int start = min(data->items.getCount() - 1, max(0, wParam)); + int end = min(data->items.getCount() - 1, max(0, lParam)); + if (start > end) { start ^= end; end ^= start; start ^= end; } int count = data->items.getCount(); - for (int i = 0; i < count; ++i) - { - if ((i >= start) && (i <= end)) - { + for (int i = 0; i < count; ++i) { + if ((i >= start) && (i <= end)) { data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; - } else - { + } + else { data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED); } } @@ -201,12 +190,11 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return 0; } - case NSM_DESELECTITEMS: + case NSM_DESELECTITEMS: { - int start = min(data->items.getCount()-1, max(0, wParam)); - int end = min(data->items.getCount()-1, max(0, lParam)); - if (start > end) - { + int start = min(data->items.getCount() - 1, max(0, wParam)); + int end = min(data->items.getCount() - 1, max(0, lParam)); + if (start > end) { start ^= end; end ^= start; start ^= end; @@ -217,13 +205,13 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return 0; } - case NSM_ENSUREVISIBLE: + case NSM_ENSUREVISIBLE: { EnsureVisible(hwnd, data, wParam); return 0; } - case NSM_GETITEMFROMPIXEL: + case NSM_GETITEMFROMPIXEL: { RECT rc; GetClientRect(hwnd, &rc); @@ -232,8 +220,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM DWORD current = data->scrollTopItem; int top = data->scrollTopPixel; int bottom = top + LayoutItem(hwnd, &data->items, current); - while (top <= height) - { + while (top <= height) { if ((lParam >= top) && (lParam <= bottom)) return current; if (++current >= count) @@ -244,56 +231,50 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return -1; } - case NSM_SETCARET: + case NSM_SETCARET: { - if ((wParam >= 0) && (wParam < data->items.getCount())) - { + if ((wParam >= 0) && (wParam < data->items.getCount())) { data->caret = wParam; - if (lParam) - { + if (lParam) { SendMessage(hwnd, NSM_ENSUREVISIBLE, data->caret, 0); } } } - case NSM_GETCARET: + case NSM_GETCARET: { return data->caret; } - case NSM_FINDNEXT: + case NSM_FINDNEXT: { int id = data->items.FindNext(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (TCHAR *)wParam)); - if (id >= 0) - { + if (id >= 0) { SendMessage(hwnd, NSM_SELECTITEMS2, id, id); SendMessage(hwnd, NSM_SETCARET, id, TRUE); } return id; } - case NSM_FINDPREV: + case NSM_FINDPREV: { int id = data->items.FindPrev(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (TCHAR *)wParam)); - if (id >= 0) - { + if (id >= 0) { SendMessage(hwnd, NSM_SELECTITEMS2, id, id); SendMessage(hwnd, NSM_SETCARET, id, TRUE); } return id; } - case NSM_COPY: + case NSM_COPY: { TCHAR *res = 0; TCHAR *buf; int eventCount = data->items.getCount(); - for (int i = 0; i < eventCount; i++) - { + for (int i = 0; i < eventCount; i++) { HistoryArray::ItemData *item = data->items.get(i, ELM_NOTHING); - if (item->flags&HIF_SELECTED) - { + if (item->flags&HIF_SELECTED) { buf = TplFormatString(TPL_COPY_MESSAGE, item->hContact, item); res = appendString(res, buf); free(buf); @@ -304,50 +285,50 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM free(res); } // End of history list control messages - case WM_SIZE: - InvalidateRect(hwnd, 0, FALSE); - break; + case WM_SIZE: + InvalidateRect(hwnd, 0, FALSE); + break; - case WM_ERASEBKGND: - return 1; + case WM_ERASEBKGND: + return 1; - case WM_PRINTCLIENT: + case WM_PRINTCLIENT: { -// PaintClc(hwnd, dat, (HDC) wParam, NULL); + // PaintClc(hwnd, dat, (HDC) wParam, NULL); break; } -/* - case WM_NCPAINT: - { - RECT rc; - GetWindowRect(hwnd, &rc); + /* + case WM_NCPAINT: + { + RECT rc; + GetWindowRect(hwnd, &rc); - HDC hdc; - hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN); - FrameRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); - ReleaseDC(hwnd, hdc); - } -*/ -/* - case WM_NCPAINT: - { - if (wParam == 1) - break; - { - POINT ptTopLeft = { 0, 0 }; - HRGN hClientRgn; - ClientToScreen(hwnd, &ptTopLeft); - hClientRgn = CreateRectRgn(0, 0, 1, 1); - CombineRgn(hClientRgn, (HRGN) wParam, NULL, RGN_COPY); - OffsetRgn(hClientRgn, -ptTopLeft.x, -ptTopLeft.y); - InvalidateRgn(hwnd, hClientRgn, FALSE); - DeleteObject(hClientRgn); - UpdateWindow(hwnd); - } - break; - } -*/ - case WM_PAINT: + HDC hdc; + hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN); + FrameRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); + ReleaseDC(hwnd, hdc); + } + */ + /* + case WM_NCPAINT: + { + if (wParam == 1) + break; + { + POINT ptTopLeft = { 0, 0 }; + HRGN hClientRgn; + ClientToScreen(hwnd, &ptTopLeft); + hClientRgn = CreateRectRgn(0, 0, 1, 1); + CombineRgn(hClientRgn, (HRGN) wParam, NULL, RGN_COPY); + OffsetRgn(hClientRgn, -ptTopLeft.x, -ptTopLeft.y); + InvalidateRgn(hwnd, hClientRgn, FALSE); + DeleteObject(hClientRgn); + UpdateWindow(hwnd); + } + break; + } + */ + case WM_PAINT: { HDC hdcWindow; PAINTSTRUCT ps; @@ -356,14 +337,13 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM /* we get so many InvalidateRect()'s that there is no point painting, Windows in theory shouldn't queue up WM_PAINTs in this case but it does so we'll just ignore them */ - if (IsWindowVisible(hwnd)) - { + if (IsWindowVisible(hwnd)) { RECT rc; GetClientRect(hwnd, &rc); -// HDC hdc = hdcWindow; + // HDC hdc = hdcWindow; HDC hdc = CreateCompatibleDC(hdcWindow); - HBITMAP hbmSave = (HBITMAP)SelectObject(hdc, CreateCompatibleBitmap(hdcWindow, rc.right-rc.left, rc.bottom-rc.top)); + HBITMAP hbmSave = (HBITMAP)SelectObject(hdc, CreateCompatibleBitmap(hdcWindow, rc.right - rc.left, rc.bottom - rc.top)); GetClientRect(hwnd, &rc); int height = rc.bottom - rc.top; @@ -373,13 +353,12 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM while ((top < height) && (idx < data->items.getCount())) top += PaintItem(hdc, &data->items, idx++, top, width); - if (top <= height) - { + if (top <= height) { RECT rc2; SetRect(&rc2, 0, top, width, height); - + HBRUSH hbr; - hbr = CreateSolidBrush(RGB(0xff,0xff,0xff)); + hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff)); FillRect(hdc, &rc2, hbr); DeleteObject(hbr); } @@ -387,7 +366,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM GetWindowRect(hwnd, &rc); rc.right -= rc.left; rc.left = 0; rc.bottom -= rc.top; rc.top = 0; - DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT); + DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT); BitBlt(hdcWindow, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY); DeleteObject(SelectObject(hdc, hbmSave)); @@ -398,68 +377,65 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; } - case WM_SETFOCUS: + case WM_SETFOCUS: { return 0; } - case WM_GETDLGCODE: + case WM_GETDLGCODE: { - if (lParam) - { - MSG *msg2 = (MSG *) lParam; - if (msg2->message == WM_KEYDOWN) - { + if (lParam) { + MSG *msg2 = (MSG *)lParam; + if (msg2->message == WM_KEYDOWN) { if (msg2->wParam == VK_TAB) return 0; if (msg2->wParam == VK_ESCAPE && !data->hwndEditBox) return 0; - } else - if (msg2->message == WM_CHAR) - { - if (msg2->wParam == '\t') - return 0; - if (msg2->wParam == 27 && !data->hwndEditBox) - return 0; } + else + if (msg2->message == WM_CHAR) { + if (msg2->wParam == '\t') + return 0; + if (msg2->wParam == 27 && !data->hwndEditBox) + return 0; + } } return DLGC_WANTMESSAGE; } - case WM_KEYDOWN: + case WM_KEYDOWN: { - switch (wParam) - { - case VK_UP: + switch (wParam) { + case VK_UP: { - SendMessage(hwnd, NSM_SELECTITEMS2, data->caret-1, data->caret-1); - SendMessage(hwnd, NSM_SETCARET, data->caret-1, TRUE); + SendMessage(hwnd, NSM_SELECTITEMS2, data->caret - 1, data->caret - 1); + SendMessage(hwnd, NSM_SETCARET, data->caret - 1, TRUE); break; } - case VK_DOWN: + case VK_DOWN: { - SendMessage(hwnd, NSM_SELECTITEMS2, data->caret+1, data->caret+1); - SendMessage(hwnd, NSM_SETCARET, data->caret+1, TRUE); + SendMessage(hwnd, NSM_SELECTITEMS2, data->caret + 1, data->caret + 1); + SendMessage(hwnd, NSM_SETCARET, data->caret + 1, TRUE); break; } - case VK_PRIOR: + case VK_PRIOR: { break; } - case VK_NEXT: + case VK_NEXT: { break; } - case VK_HOME: + case VK_HOME: { break; } - case VK_END: + case VK_END: { break; } - case VK_F2: + case VK_F2: { BeginEditItem(hwnd, data, data->caret); break; @@ -468,66 +444,61 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; } - case WM_SYSCHAR: - case WM_CHAR: + case WM_SYSCHAR: + case WM_CHAR: { - if (wParam == 27) - { + if (wParam == 27) { if (data->hwndEditBox) EndEditItem(hwnd, data); - } else - { - char ch = MapVirtualKey((lParam>>16)&0xff, 1); - if (((ch == 'C') || (ch == VK_INSERT)) && (GetKeyState(VK_CONTROL)&0x80)) - { + } + else { + char ch = MapVirtualKey((lParam >> 16) & 0xff, 1); + if (((ch == 'C') || (ch == VK_INSERT)) && (GetKeyState(VK_CONTROL) & 0x80)) { PostMessage(hwnd, NSM_COPY, 0, 0); - } else - if ((ch == 'A') && (GetKeyState(VK_CONTROL)&0x80)) - { - SendMessage(hwnd, NSM_SELECTITEMS, 0, data->items.getCount()); -// } else -// if (ch == VK_ESCAPE) -// { -// PostMessage(GetParent(hwnd), WM_CLOSE, 0, 0); } + else + if ((ch == 'A') && (GetKeyState(VK_CONTROL) & 0x80)) { + SendMessage(hwnd, NSM_SELECTITEMS, 0, data->items.getCount()); + // } else + // if (ch == VK_ESCAPE) + // { + // PostMessage(GetParent(hwnd), WM_CLOSE, 0, 0); + } } break; } - case WM_LBUTTONDOWN: + case WM_LBUTTONDOWN: { int item = SendMessage(hwnd, NSM_GETITEMFROMPIXEL, LOWORD(lParam), HIWORD(lParam)); - if (item >= 0) - { + if (item >= 0) { if (data->caret != item) EndEditItem(hwnd, data); - if (wParam & MK_CONTROL) - { + if (wParam & MK_CONTROL) { SendMessage(hwnd, NSM_TOGGLEITEMS, item, item); SendMessage(hwnd, NSM_SETCARET, item, TRUE); - } else - if (wParam & MK_SHIFT) - { - SendMessage(hwnd, NSM_SELECTITEMS, data->caret, item); - SendMessage(hwnd, NSM_SETCARET, item, TRUE); - } else - { - if (data->caret == item) - { - BeginEditItem(hwnd, data, item); - } else - { - SendMessage(hwnd, NSM_SELECTITEMS2, item, item); + } + else + if (wParam & MK_SHIFT) { + SendMessage(hwnd, NSM_SELECTITEMS, data->caret, item); SendMessage(hwnd, NSM_SETCARET, item, TRUE); } - } + else { + if (data->caret == item) { + BeginEditItem(hwnd, data, item); + } + else { + SendMessage(hwnd, NSM_SELECTITEMS2, item, item); + SendMessage(hwnd, NSM_SETCARET, item, TRUE); + } + } } SetFocus(hwnd); return 0; } - case WM_MOUSEWHEEL: + case WM_MOUSEWHEEL: { DWORD s_scrollTopItem = data->scrollTopItem; int s_scrollTopPixel = data->scrollTopPixel; @@ -543,57 +514,55 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return TRUE; } - case WM_VSCROLL: + case WM_VSCROLL: { DWORD s_scrollTopItem = data->scrollTopItem; int s_scrollTopPixel = data->scrollTopPixel; - switch (LOWORD(wParam)) - { - case SB_LINEUP: - ScrollListBy(hwnd, data, 0, 10); - break; - case SB_LINEDOWN: - ScrollListBy(hwnd, data, 0, -10); - break; - case SB_PAGEUP: - ScrollListBy(hwnd, data, -10, 0); - break; - case SB_PAGEDOWN: - ScrollListBy(hwnd, data, 10, 0); - break; - case SB_BOTTOM: - data->scrollTopItem = data->items.getCount()-1; - data->scrollTopPixel = 0; - break; - case SB_TOP: - data->scrollTopItem = 0; - data->scrollTopPixel = 0; - break; - case SB_THUMBTRACK: + switch (LOWORD(wParam)) { + case SB_LINEUP: + ScrollListBy(hwnd, data, 0, 10); + break; + case SB_LINEDOWN: + ScrollListBy(hwnd, data, 0, -10); + break; + case SB_PAGEUP: + ScrollListBy(hwnd, data, -10, 0); + break; + case SB_PAGEDOWN: + ScrollListBy(hwnd, data, 10, 0); + break; + case SB_BOTTOM: + data->scrollTopItem = data->items.getCount() - 1; + data->scrollTopPixel = 0; + break; + case SB_TOP: + data->scrollTopItem = 0; + data->scrollTopPixel = 0; + break; + case SB_THUMBTRACK: { SCROLLINFO si; si.cbSize = sizeof(si); - si.fMask = SIF_TRACKPOS|SIF_RANGE; + si.fMask = SIF_TRACKPOS | SIF_RANGE; GetScrollInfo(hwnd, SB_VERT, &si); int pos = si.nTrackPos; - if (pos == si.nMax) - { + if (pos == si.nMax) { data->scrollTopItem = data->items.getCount(); data->scrollTopPixel = -1000; - } else - { - data->scrollTopItem = pos/AVERAGE_ITEM_HEIGHT; + } + else { + data->scrollTopItem = pos / AVERAGE_ITEM_HEIGHT; int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); - data->scrollTopPixel = -pos%AVERAGE_ITEM_HEIGHT * itemHeight / AVERAGE_ITEM_HEIGHT; + data->scrollTopPixel = -pos % AVERAGE_ITEM_HEIGHT * itemHeight / AVERAGE_ITEM_HEIGHT; } FixScrollPosition(hwnd, data); break; } - default: - return 0; + default: + return 0; } if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel)) @@ -601,7 +570,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; } - case WM_DESTROY: + case WM_DESTROY: { delete data; SetWindowLongPtr(hwnd, 0, 0); @@ -616,64 +585,56 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM // Utilities static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int scrollPixels) { - if (scrollItems) - { + if (scrollItems) { data->scrollTopItem += scrollItems; data->scrollTopPixel = 0; - } else - if (scrollPixels) - { - data->scrollTopPixel += scrollPixels; - if (data->scrollTopPixel > 0) - { - while ((data->scrollTopPixel > 0) && data->scrollTopItem) - { - data->scrollTopItem--; - int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); - data->scrollTopPixel -= itemHeight; - } + } + else + if (scrollPixels) { + data->scrollTopPixel += scrollPixels; + if (data->scrollTopPixel > 0) { + while ((data->scrollTopPixel > 0) && data->scrollTopItem) { + data->scrollTopItem--; + int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); + data->scrollTopPixel -= itemHeight; + } - if (data->scrollTopPixel > 0) - { - data->scrollTopPixel = 0; - } - } else - if (data->scrollTopPixel < 0) - { - int maxItem = data->items.getCount(); - int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); - while ((-data->scrollTopPixel > itemHeight) && (data->scrollTopItem < maxItem)) - { - data->scrollTopPixel += itemHeight; - data->scrollTopItem++; - itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); + if (data->scrollTopPixel > 0) { + data->scrollTopPixel = 0; + } } + else + if (data->scrollTopPixel < 0) { + int maxItem = data->items.getCount(); + int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); + while ((-data->scrollTopPixel > itemHeight) && (data->scrollTopItem < maxItem)) { + data->scrollTopPixel += itemHeight; + data->scrollTopItem++; + itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem); + } + } } - } FixScrollPosition(hwnd, data); } static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item) { - if (data->scrollTopItem >= item) - { + if (data->scrollTopItem >= item) { data->scrollTopItem = item; data->scrollTopPixel = 0; - } else - { + } + else { RECT rc; GetClientRect(hwnd, &rc); int height = rc.bottom - rc.top; int top = data->scrollTopPixel; int idx = data->scrollTopItem; int itemHeight = LayoutItem(hwnd, &data->items, idx); bool found = false; - while (top < height) - { - if (idx == item) - { + while (top < height) { + if (idx == item) { itemHeight = LayoutItem(hwnd, &data->items, idx); if (top + itemHeight > height) - ScrollListBy(hwnd, data, 0, height-top-itemHeight); + ScrollListBy(hwnd, data, 0, height - top - itemHeight); found = true; break; } @@ -681,8 +642,7 @@ static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item) idx++; itemHeight = LayoutItem(hwnd, &data->items, idx); } - if (!found) - { + if (!found) { data->scrollTopItem = item; data->scrollTopPixel = 0; } @@ -698,25 +658,22 @@ static void FixScrollPosition(HWND hwnd, NewstoryListData *data) GetWindowRect(hwnd, &rc); int windowHeight = rc.bottom - rc.top; - if (windowHeight != data->cachedWindowHeight) - { + if (windowHeight != data->cachedWindowHeight) { int maxTopItem = 0; int tmp = 0; - for (maxTopItem = data->items.getCount(); (maxTopItem>0) && (tmp < windowHeight); maxTopItem--) - tmp += LayoutItem(hwnd, &data->items, maxTopItem-1); + for (maxTopItem = data->items.getCount(); (maxTopItem > 0) && (tmp < windowHeight); maxTopItem--) + tmp += LayoutItem(hwnd, &data->items, maxTopItem - 1); data->cachedMaxTopItem = maxTopItem; data->cachedWindowHeight = windowHeight; data->cachedMaxTopPixel = (windowHeight < tmp) ? windowHeight - tmp : 0; } - if (data->scrollTopItem < 0) - { + if (data->scrollTopItem < 0) { data->scrollTopItem = 0; } if ((data->scrollTopItem > data->cachedMaxTopItem) || - ((data->scrollTopItem == data->cachedMaxTopItem) && (data->scrollTopPixel < data->cachedMaxTopPixel))) - { + ((data->scrollTopItem == data->cachedMaxTopItem) && (data->scrollTopPixel < data->cachedMaxTopPixel))) { data->scrollTopItem = data->cachedMaxTopItem; data->scrollTopPixel = data->cachedMaxTopPixel; } @@ -725,7 +682,7 @@ static void FixScrollPosition(HWND hwnd, NewstoryListData *data) static void RecalcScrollBar(HWND hwnd, NewstoryListData *data) { - SCROLLINFO si = {0}; + SCROLLINFO si = { 0 }; RECT clRect; GetClientRect(hwnd, &clRect); si.cbSize = sizeof(si); @@ -751,66 +708,63 @@ static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index) int top = data->scrollTopPixel; int idx = data->scrollTopItem; int itemHeight = LayoutItem(hwnd, &data->items, idx); - while (top < height) - { - if (idx == index) - { + while (top < height) { + if (idx == index) { HistoryArray::ItemData *item = data->items.get(index, ELM_DATA); int tpl; int fontid; int colorid; - switch (item->dbe.eventType) - { - case EVENTTYPE_MESSAGE: - tpl = TPL_COPY_MESSAGE; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INMSG : COLOR_OUTMSG; - break; + switch (item->dbe.eventType) { + case EVENTTYPE_MESSAGE: + tpl = TPL_COPY_MESSAGE; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INMSG : COLOR_OUTMSG; + break; - case EVENTTYPE_FILE: - tpl = TPL_COPY_FILE; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INFILE : COLOR_OUTFILE; - break; + case EVENTTYPE_FILE: + tpl = TPL_COPY_FILE; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INFILE : COLOR_OUTFILE; + break; - case EVENTTYPE_URL: - tpl = TPL_COPY_URL; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INURL : FONT_OUTURL; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INURL : COLOR_OUTURL; - break; + case EVENTTYPE_URL: + tpl = TPL_COPY_URL; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INURL : FONT_OUTURL; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INURL : COLOR_OUTURL; + break; - case EVENTTYPE_STATUSCHANGE: - tpl = TPL_COPY_SIGN; - fontid = FONT_STATUS; - colorid = COLOR_STATUS; - break; + case EVENTTYPE_STATUSCHANGE: + tpl = TPL_COPY_SIGN; + fontid = FONT_STATUS; + colorid = COLOR_STATUS; + break; - case EVENTTYPE_AUTHREQUEST: - tpl = TPL_COPY_AUTH; - fontid = FONT_INOTHER; - colorid = COLOR_INOTHER; - break; + case EVENTTYPE_AUTHREQUEST: + tpl = TPL_COPY_AUTH; + fontid = FONT_INOTHER; + colorid = COLOR_INOTHER; + break; - case EVENTTYPE_ADDED: - tpl = TPL_COPY_ADDED; - fontid = FONT_INOTHER; - colorid = COLOR_INOTHER; - break; - - default: - tpl = TPL_COPY_OTHER; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; - break; + case EVENTTYPE_ADDED: + tpl = TPL_COPY_ADDED; + fontid = FONT_INOTHER; + colorid = COLOR_INOTHER; + break; + + default: + tpl = TPL_COPY_OTHER; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; + break; } TCHAR *text = TplFormatString(tpl, item->hContact, item); - data->hwndEditBox = CreateWindow(_T("EDIT"), text, WS_CHILD|WS_BORDER|ES_READONLY|ES_MULTILINE|ES_AUTOVSCROLL, 0, top, rc.right-rc.left, itemHeight, hwnd, NULL, g_plugin.getInst(), NULL); + data->hwndEditBox = CreateWindow(_T("EDIT"), text, WS_CHILD | WS_BORDER | ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL, 0, top, rc.right - rc.left, itemHeight, hwnd, NULL, g_plugin.getInst(), NULL); OldEditWndProc = (WNDPROC)SetWindowLongPtr(data->hwndEditBox, GWLP_WNDPROC, (LONG_PTR)HistoryEditWndProc); SendMessage(data->hwndEditBox, WM_SETFONT, (WPARAM)fonts[fontid].hfnt, 0); SendMessage(data->hwndEditBox, EM_SETMARGINS, EC_RIGHTMARGIN, 100); - SendMessage(data->hwndEditBox, EM_SETSEL, 0, (LPARAM) (-1)); + SendMessage(data->hwndEditBox, EM_SETSEL, 0, (LPARAM)(-1)); ShowWindow(data->hwndEditBox, SW_SHOW); SetFocus(data->hwndEditBox); free(text); @@ -832,62 +786,59 @@ static int LayoutItem(HWND hwnd, HistoryArray *items, int index) { HDC hdc = GetDC(hwnd); RECT rc; GetClientRect(hwnd, &rc); - int width = rc.right-rc.left; + int width = rc.right - rc.left; HistoryArray::ItemData *item = items->get(index, ELM_DATA); if (!item) return 0; int tpl; int fontid; - switch (item->dbe.eventType) - { - case EVENTTYPE_MESSAGE: - tpl = TPL_MESSAGE; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; - break; + switch (item->dbe.eventType) { + case EVENTTYPE_MESSAGE: + tpl = TPL_MESSAGE; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; + break; - case EVENTTYPE_FILE: - tpl = TPL_FILE; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; - break; + case EVENTTYPE_FILE: + tpl = TPL_FILE; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; + break; - case EVENTTYPE_URL: - tpl = TPL_URL; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INURL : FONT_OUTURL; - break; + case EVENTTYPE_URL: + tpl = TPL_URL; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INURL : FONT_OUTURL; + break; - case EVENTTYPE_STATUSCHANGE: - tpl = TPL_SIGN; - fontid = FONT_STATUS; - break; + case EVENTTYPE_STATUSCHANGE: + tpl = TPL_SIGN; + fontid = FONT_STATUS; + break; - case EVENTTYPE_AUTHREQUEST: - tpl = TPL_AUTH; - fontid = FONT_INOTHER; - break; + case EVENTTYPE_AUTHREQUEST: + tpl = TPL_AUTH; + fontid = FONT_INOTHER; + break; - case EVENTTYPE_ADDED: - tpl = TPL_ADDED; - fontid = FONT_INOTHER; - break; + case EVENTTYPE_ADDED: + tpl = TPL_ADDED; + fontid = FONT_INOTHER; + break; - default: - tpl = TPL_OTHER; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - break; + default: + tpl = TPL_OTHER; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; + break; } - HFONT hfnt = (HFONT)SelectObject(hdc, fonts[fontid].hfnt); -// HANDLE hText = (HANDLE)item->data; - if (!item->data) - { + HFONT hfnt = (HFONT)SelectObject(hdc, fonts[fontid].hfnt); + if (!item->data) { TCHAR *buf = TplFormatString(tpl, item->hContact, item); item->data = MTextCreateT(htuLog, buf); free(buf); } SIZE sz; - sz.cx = width-6; + sz.cx = width - 6; MTextMeasure(hdc, &sz, (HANDLE)item->data); SelectObject(hdc, hfnt); @@ -901,71 +852,68 @@ static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width if (!items) return 0; HistoryArray::ItemData *item = items->get(index, ELM_DATA); -// LOGFONT lfText; + // LOGFONT lfText; COLORREF clText, clBack, clLine; int tpl; int fontid; int colorid; - switch (item->dbe.eventType) - { - case EVENTTYPE_MESSAGE: - tpl = TPL_MESSAGE; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INMSG : COLOR_OUTMSG; - break; + switch (item->dbe.eventType) { + case EVENTTYPE_MESSAGE: + tpl = TPL_MESSAGE; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INMSG : FONT_OUTMSG; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INMSG : COLOR_OUTMSG; + break; - case EVENTTYPE_FILE: - tpl = TPL_FILE; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INFILE : COLOR_OUTFILE; - break; + case EVENTTYPE_FILE: + tpl = TPL_FILE; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INFILE : FONT_OUTFILE; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INFILE : COLOR_OUTFILE; + break; - case EVENTTYPE_URL: - tpl = TPL_URL; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INURL : FONT_OUTURL; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INURL : COLOR_OUTURL; - break; + case EVENTTYPE_URL: + tpl = TPL_URL; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INURL : FONT_OUTURL; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INURL : COLOR_OUTURL; + break; - case EVENTTYPE_STATUSCHANGE: - tpl = TPL_SIGN; - fontid = FONT_STATUS; - colorid = COLOR_STATUS; - break; + case EVENTTYPE_STATUSCHANGE: + tpl = TPL_SIGN; + fontid = FONT_STATUS; + colorid = COLOR_STATUS; + break; - case EVENTTYPE_AUTHREQUEST: - tpl = TPL_AUTH; - fontid = FONT_INOTHER; - colorid = COLOR_INOTHER; - break; + case EVENTTYPE_AUTHREQUEST: + tpl = TPL_AUTH; + fontid = FONT_INOTHER; + colorid = COLOR_INOTHER; + break; - case EVENTTYPE_ADDED: - tpl = TPL_ADDED; - fontid = FONT_INOTHER; - colorid = COLOR_INOTHER; - break; - - default: - tpl = TPL_OTHER; - fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; - colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; - break; + case EVENTTYPE_ADDED: + tpl = TPL_ADDED; + fontid = FONT_INOTHER; + colorid = COLOR_INOTHER; + break; + + default: + tpl = TPL_OTHER; + fontid = !(item->dbe.flags&DBEF_SENT) ? FONT_INOTHER : FONT_OUTOTHER; + colorid = !(item->dbe.flags&DBEF_SENT) ? COLOR_INOTHER : COLOR_OUTOTHER; + break; } clText = fonts[fontid].cl; - if (item->flags & HIF_SELECTED) - { + if (item->flags & HIF_SELECTED) { MTextSendMessage(0, item->data, EM_SETSEL, 0, -1); -// clText = colors[COLOR_SELTEXT].cl; + // clText = colors[COLOR_SELTEXT].cl; clLine = GetSysColor(COLOR_HIGHLIGHTTEXT); clBack = GetSysColor(COLOR_HIGHLIGHT); //colors[COLOR_SELECTED].cl; - } else - { + } + else { MTextSendMessage(0, item->data, EM_SETSEL, 0, 0); clLine = colors[COLOR_SELECTED].cl; clBack = colors[colorid].cl; } - if (!item->data) - { + if (!item->data) { TCHAR *buf = TplFormatString(tpl, item->hContact, item); item->data = MTextCreateT(htuLog, buf); free(buf); @@ -974,14 +922,14 @@ static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width } SIZE sz; - sz.cx = width-6; + sz.cx = width - 6; HFONT hfnt = (HFONT)SelectObject(hdc, fonts[fontid].hfnt); MTextMeasure(hdc, &sz, (HANDLE)item->data); SelectObject(hdc, hfnt); int height = sz.cy + 5; RECT rc; - SetRect(&rc, 0, top, width, top+height); + SetRect(&rc, 0, top, width, top + height); HBRUSH hbr; hbr = CreateSolidBrush(clBack); @@ -992,16 +940,16 @@ static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width POINT pos; pos.x = 3; - pos.y = top+2; + pos.y = top + 2; hfnt = (HFONT)SelectObject(hdc, fonts[fontid].hfnt); MTextDisplay(hdc, pos, sz, (HANDLE)item->data); SelectObject(hdc, hfnt); DeleteObject(hbr); - + HPEN hpn = (HPEN)SelectObject(hdc, CreatePen(PS_SOLID, 1, clLine)); - MoveToEx(hdc, rc.left, rc.bottom-1, 0); - LineTo(hdc, rc.right, rc.bottom-1); + MoveToEx(hdc, rc.left, rc.bottom - 1, 0); + LineTo(hdc, rc.right, rc.bottom - 1); DeleteObject(SelectObject(hdc, hpn)); return height; diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 01ca695ddd..3b857bac75 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -5,7 +5,7 @@ enum { - NSM_FIRST = WM_USER+100, + NSM_FIRST = WM_USER + 100, // wParam = fist item // lParam = last item @@ -63,4 +63,4 @@ enum void InitNewstoryControl(); //void DestroyNewstoryControl(); -#endif // __history_control_h__
\ No newline at end of file +#endif // __history_control_h__ diff --git a/plugins/NewStory/src/icons.cpp b/plugins/NewStory/src/icons.cpp index 36bf44344b..bcf04b1324 100644 --- a/plugins/NewStory/src/icons.cpp +++ b/plugins/NewStory/src/icons.cpp @@ -33,8 +33,6 @@ static IconItem icons[] = { LPGEN("Save Password"), "savepass", ICO_SAVEPASS } }; -//int iconCount = sizeof(icons) / sizeof(icons[0]); - int evtIconsChanged(WPARAM, LPARAM) { //RefreshIcons(icons, ICO_COUNT); @@ -61,4 +59,4 @@ HICON GetIcon(int iconId) if (it.defIconID == iconId) return IcoLib_GetIconByHandle(it.hIcolib); return nullptr; -}
\ No newline at end of file +} diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp index 7adffe0f83..ebce994534 100644 --- a/plugins/NewStory/src/main.cpp +++ b/plugins/NewStory/src/main.cpp @@ -11,7 +11,7 @@ #include "stdafx.h" -HANDLE hhkModulesLoaded=0, hhkOptInitialise=0, hhkTTBLoaded=0; +HANDLE hhkModulesLoaded = 0, hhkOptInitialise = 0, hhkTTBLoaded = 0; CMPlugin g_plugin; @@ -33,7 +33,8 @@ PLUGININFOEX pluginInfoEx = CMPlugin::CMPlugin() : PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx) -{} +{ +} ///////////////////////////////////////////////////////////////////////////////////////// @@ -74,13 +75,13 @@ int CMPlugin::Load() CreateServiceFunction("Newstory/System", svcShowSystemNewstory); hhkModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, evtModulesLoaded); -/* - hhkOptInitialise = HookEvent(ME_OPT_INITIALISE, OptInitialise); + /* + hhkOptInitialise = HookEvent(ME_OPT_INITIALISE, OptInitialise); - options.fnup = options.fndown = 0; - options.flags = 0; - LoadOptions(); -*/ + options.fnup = options.fndown = 0; + options.flags = 0; + LoadOptions(); + */ return 0; } @@ -89,13 +90,13 @@ int CMPlugin::Load() int CMPlugin::Unload() { UnhookEvent(hhkModulesLoaded); -/* - UnhookEvent(hhkOptInitialise); - if (hhkTTBLoaded) - UnhookEvent(hhkTTBLoaded); + /* + UnhookEvent(hhkOptInitialise); + if (hhkTTBLoaded) + UnhookEvent(hhkTTBLoaded); - DoCleanup(); -*/ + DoCleanup(); + */ FreeHistory(); return 0; } diff --git a/plugins/NewStory/src/opt_passwords.cpp b/plugins/NewStory/src/opt_passwords.cpp index eb9be44eaa..3427def74d 100644 --- a/plugins/NewStory/src/opt_passwords.cpp +++ b/plugins/NewStory/src/opt_passwords.cpp @@ -25,10 +25,8 @@ static void ResetListOptions(HWND hwndList) INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) { HTREEITEM hitmGlobal, hitmMaster; - switch (msg) - { + switch (msg) { case WM_INITDIALOG: - { HIMAGELIST himg; himg = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 3, 3); icoidNoPassword = ImageList_AddIcon(himg, GetIcon(ICO_NOPASSWORD)); @@ -36,19 +34,19 @@ INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)himg); SendDlgItemMessage(hwnd, IDC_LIST, CLM_SETEXTRACOLUMNS, 1, 0); + { + CLCINFOITEM cii = { 0 }; + cii.cbSize = sizeof(cii); + cii.flags = CLCIIF_GROUPFONT; - CLCINFOITEM cii = { 0 }; - cii.cbSize = sizeof(cii); - cii.flags = CLCIIF_GROUPFONT; - - cii.pszText = TranslateT("** Global **"); - hitmGlobal = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); - SendMessage(GetDlgItem(hwnd, IDC_LIST), CLM_SETEXTRAIMAGE, (WPARAM)hitmGlobal, MAKELPARAM(0, icoidNoPassword)); - - cii.pszText = TranslateT("** Master **"); - hitmMaster = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); - SendMessage(GetDlgItem(hwnd, IDC_LIST), CLM_SETEXTRAIMAGE, (WPARAM)hitmMaster, MAKELPARAM(0, icoidNoPassword)); + cii.pszText = TranslateT("** Global **"); + hitmGlobal = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); + SendMessage(GetDlgItem(hwnd, IDC_LIST), CLM_SETEXTRAIMAGE, (WPARAM)hitmGlobal, MAKELPARAM(0, icoidNoPassword)); + cii.pszText = TranslateT("** Master **"); + hitmMaster = (HTREEITEM)SendDlgItemMessage(hwnd, IDC_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); + SendMessage(GetDlgItem(hwnd, IDC_LIST), CLM_SETEXTRAIMAGE, (WPARAM)hitmMaster, MAKELPARAM(0, icoidNoPassword)); + } SetAllContactIcons(GetDlgItem(hwnd, IDC_LIST)); ResetListOptions(GetDlgItem(hwnd, IDC_LIST)); @@ -59,40 +57,31 @@ INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) SendMessage(GetDlgItem(hwnd, IDC_SAVEPASSWORD), BUTTONADDTOOLTIP, (WPARAM)Translate("Save Password"), 0); SendMessage(GetDlgItem(hwnd, IDC_SAVEPASSWORD), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_SAVEPASS)); return TRUE; - } case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) - { + switch (((LPNMHDR)lParam)->idFrom) { case 0: - { - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case PSN_RESET: - { return TRUE; - } case PSN_APPLY: - { return TRUE; } - } break; - } case IDC_LIST: - { - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case CLN_NEWCONTACT: case CLN_LISTREBUILT: SetAllContactIcons(GetDlgItem(hwnd, IDC_LIST)); + break; //fall through // case CLN_CONTACTMOVED: // SetListGroupIcons(GetDlgItem(hwndDlg,IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETNEXTITEM,CLGN_ROOT,0),hItemAll,NULL); // break; -// case CLN_OPTIONSCHANGED: + + case CLN_OPTIONSCHANGED: ResetListOptions(GetDlgItem(hwnd, IDC_LIST)); break; /* @@ -155,7 +144,6 @@ INT_PTR CALLBACK OptPasswordsDlgProc(HWND hwnd, UINT msg, WPARAM, LPARAM lParam) } return TRUE; } - } break; } return FALSE; diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp index 14c1d056a3..c3e92fd117 100644 --- a/plugins/NewStory/src/options.cpp +++ b/plugins/NewStory/src/options.cpp @@ -1,24 +1,6 @@ #include "stdafx.h" Options options; -int OptShowPage = 0; - -#undef MODULENAME -#define MODULENAME "PopUp" - -void LoadOptions() -{ - return; -} - -static int OptionsInitialize(WPARAM wParam, LPARAM lParam); - -void InitOptions() -{ - HookEvent(ME_OPT_INITIALISE, OptionsInitialize); -} - -INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); static int OptionsInitialize(WPARAM wParam, LPARAM) { @@ -26,136 +8,26 @@ static int OptionsInitialize(WPARAM wParam, LPARAM) odp.position = 100000000; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); odp.szTitle.w = LPGENW("Newstory"); - // odp.pszGroup = Translate("PopUps"); - //odp.position = 910000000; odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE; - odp.pfnDlgProc = OptionsDlgProc; + + // odp.szTab.w = LPGENW("General"); + // odp.pfnDlgProc = 0; + // odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_GENERAL); + // g_plugin.addOptions(wParam, &odp); + + odp.szTab.w = LPGENW("Templates"); + odp.pfnDlgProc = OptTemplatesDlgProc; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_TEMPLATES); g_plugin.addOptions(wParam, &odp); - return 0; -} -static void ThemeDialogBackground(HWND hwnd) { - //if (IsWinVerXPPlus()) - { - static HMODULE hThemeAPI = NULL; - if (!hThemeAPI) hThemeAPI = GetModuleHandle(_T("uxtheme")); - if (hThemeAPI) { - HRESULT(STDAPICALLTYPE *MyEnableThemeDialogTexture)(HWND, DWORD) = (HRESULT(STDAPICALLTYPE*)(HWND, DWORD))GetProcAddress(hThemeAPI, "EnableThemeDialogTexture"); - if (MyEnableThemeDialogTexture) - MyEnableThemeDialogTexture(hwnd, 0x00000002 | 0x00000004); //0x00000002|0x00000004=ETDT_ENABLETAB - } - } + odp.szTab.w = LPGENW("Passwords (not ready yet)"); + odp.pfnDlgProc = OptPasswordsDlgProc; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_PASSWORDS); + g_plugin.addOptions(wParam, &odp); + return 0; } -INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +void InitOptions() { - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwnd); - TCITEM tci; - RECT rc; - - tci.mask = TCIF_PARAM | TCIF_TEXT; - tci.lParam = (LPARAM)CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_OPT_PASSWORDS), GetDlgItem(hwnd, IDC_TAB), OptPasswordsDlgProc); - tci.pszText = TranslateT("Passwords (not ready yet)"); - if (tci.lParam) TabCtrl_InsertItem(GetDlgItem(hwnd, IDC_TAB), 0, &tci); - GetClientRect(GetDlgItem(hwnd, IDC_TAB), &rc); - TabCtrl_AdjustRect(GetDlgItem(hwnd, IDC_TAB), FALSE, &rc); - ThemeDialogBackground((HWND)tci.lParam); - MoveWindow((HWND)tci.lParam, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); - ShowWindow((HWND)tci.lParam, (OptShowPage == 2) ? SW_SHOW : SW_HIDE); - - tci.mask = TCIF_PARAM | TCIF_TEXT; - tci.lParam = (LPARAM)CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_OPT_TEMPLATES), GetDlgItem(hwnd, IDC_TAB), OptTemplatesDlgProc); - tci.pszText = TranslateT("Templates"); - if (tci.lParam) TabCtrl_InsertItem(GetDlgItem(hwnd, IDC_TAB), 0, &tci); - GetClientRect(GetDlgItem(hwnd, IDC_TAB), &rc); - TabCtrl_AdjustRect(GetDlgItem(hwnd, IDC_TAB), FALSE, &rc); - ThemeDialogBackground((HWND)tci.lParam); - MoveWindow((HWND)tci.lParam, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); - ShowWindow((HWND)tci.lParam, (OptShowPage == 1) ? SW_SHOW : SW_HIDE); - - tci.mask = TCIF_PARAM | TCIF_TEXT; - tci.lParam = (LPARAM)CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_OPT_GENERAL), GetDlgItem(hwnd, IDC_TAB), 0); - tci.pszText = TranslateT("General"); - if (tci.lParam) TabCtrl_InsertItem(GetDlgItem(hwnd, IDC_TAB), 0, &tci); - GetClientRect(GetDlgItem(hwnd, IDC_TAB), &rc); - TabCtrl_AdjustRect(GetDlgItem(hwnd, IDC_TAB), FALSE, &rc); - ThemeDialogBackground((HWND)tci.lParam); - MoveWindow((HWND)tci.lParam, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE); - ShowWindow((HWND)tci.lParam, (OptShowPage == 0) ? SW_SHOW : SW_HIDE); - - TabCtrl_SetCurSel(GetDlgItem(hwnd, IDC_TAB), OptShowPage); - OptShowPage = 0; - return FALSE; - } - - case PSM_CHANGED: - { - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - } - - case WM_DESTROY: - { - OptShowPage = 0; - break; - } - - case WM_NOTIFY: - { - switch (((LPNMHDR)lParam)->idFrom) - { - case 0: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_RESET: - case PSN_APPLY: - { - TCITEM tci; - int i, count; - tci.mask = TCIF_PARAM; - count = TabCtrl_GetItemCount(GetDlgItem(hwnd, IDC_TAB)); - for (i = 0; i < count; i++) - { - TabCtrl_GetItem(GetDlgItem(hwnd, IDC_TAB), i, &tci); - SendMessage((HWND)tci.lParam, WM_NOTIFY, wParam, lParam); - } - break; - } - } - break; - } - - case IDC_TAB: - { - switch (((LPNMHDR)lParam)->code) - { - case TCN_SELCHANGING: - { - TCITEM tci; - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd, IDC_TAB), TabCtrl_GetCurSel(GetDlgItem(hwnd, IDC_TAB)), &tci); - ShowWindow((HWND)tci.lParam, SW_HIDE); - break; - } - case TCN_SELCHANGE: - { - TCITEM tci; - tci.mask = TCIF_PARAM; - TabCtrl_GetItem(GetDlgItem(hwnd, IDC_TAB), TabCtrl_GetCurSel(GetDlgItem(hwnd, IDC_TAB)), &tci); - ShowWindow((HWND)tci.lParam, SW_SHOW); - break; - } - } - break; - } - } - break; - } - } - return FALSE; + HookEvent(ME_OPT_INITIALISE, OptionsInitialize); } diff --git a/plugins/NewStory/src/options.h b/plugins/NewStory/src/options.h index 4912e12a02..d5cf60e1ea 100644 --- a/plugins/NewStory/src/options.h +++ b/plugins/NewStory/src/options.h @@ -7,7 +7,6 @@ struct Options }; extern Options options; -extern int OptShowPage; void LoadOptions(); void InitOptions(); diff --git a/plugins/NewStory/src/password.cpp b/plugins/NewStory/src/password.cpp index 88a8d55f36..b3184d18c0 100644 --- a/plugins/NewStory/src/password.cpp +++ b/plugins/NewStory/src/password.cpp @@ -31,7 +31,7 @@ bool CheckPassword(MCONTACT hContact, char *password) return false; } } - + db_free(&dbv); return true; } @@ -56,78 +56,66 @@ void SetPassword(MCONTACT hContact, char *password) INT_PTR CALLBACK PasswordDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { PasswordData *data = (PasswordData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - switch (msg) - { - case WM_INITDIALOG: - { - data = new PasswordData; - data->attempt = 0; - data->hContact = (MCONTACT)lParam; - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); - - RECT rc, rcMe; - SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); - GetWindowRect(hwnd, &rcMe); - SetWindowPos(hwnd, hwnd, - rc.left+((rc.right-rc.left) - (rcMe.right-rcMe.left))/2, - rc.top+((rc.bottom-rc.top) - (rcMe.bottom-rcMe.top))/2, - 0, 0, SWP_NOSIZE|SWP_NOZORDER); - - SetFocus(GetDlgItem(hwnd, IDC_PASSWORD)); - return TRUE; - } - - case WM_COMMAND: + switch (msg) { + case WM_INITDIALOG: + data = new PasswordData; + data->attempt = 0; + data->hContact = (MCONTACT)lParam; + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); + + RECT rc, rcMe; + SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); + GetWindowRect(hwnd, &rcMe); + SetWindowPos(hwnd, hwnd, + rc.left + ((rc.right - rc.left) - (rcMe.right - rcMe.left)) / 2, + rc.top + ((rc.bottom - rc.top) - (rcMe.bottom - rcMe.top)) / 2, + 0, 0, SWP_NOSIZE | SWP_NOZORDER); + + SetFocus(GetDlgItem(hwnd, IDC_PASSWORD)); + return TRUE; + + case WM_COMMAND: { - switch(LOWORD(wParam)) - { - case IDOK: + switch (LOWORD(wParam)) { + case IDOK: + data->attempt++; { - data->attempt++; int length = GetWindowTextLengthA(GetDlgItem(hwnd, IDC_PASSWORD)); - char *input = new char[length+1]; - GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD), input, length+1); - if (CheckPassword(data->hContact, input)) - { + char *input = new char[length + 1]; + GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD), input, length + 1); + if (CheckPassword(data->hContact, input)) { MessageBeep(MB_OK); EndDialog(hwnd, 1); - } else - { - if (data->attempt >= 3) - { - MessageBoxA(hwnd, "Sorry, but you've not managed to type\r\nthe correct password in 3 attempts.", "Newstory", MB_ICONHAND|MB_OK); + } + else { + if (data->attempt >= 3) { + MessageBoxA(hwnd, "Sorry, but you've not managed to type\r\nthe correct password in 3 attempts.", "Newstory", MB_ICONHAND | MB_OK); EndDialog(hwnd, 0); - } else - { + } + else { MessageBeep(MB_ICONHAND); SetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD), ""); } } - delete [] input; - return TRUE; + delete[] input; } + return TRUE; - case IDCANCEL: - { - EndDialog(hwnd, 0); - return TRUE; - } + case IDCANCEL: + EndDialog(hwnd, 0); + return TRUE; } break; } - case WM_CLOSE: - { - DestroyWindow(hwnd); - return TRUE; - } + case WM_CLOSE: + DestroyWindow(hwnd); + return TRUE; - case WM_DESTROY: - { - delete data; - data = 0; - SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - } + case WM_DESTROY: + delete data; + data = 0; + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); } return FALSE; } @@ -141,7 +129,7 @@ bool AskPassword(MCONTACT hContact) return true; } db_free(&dbv); - + if (DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_PASSWORD), 0, PasswordDlgProc, (LPARAM)hContact)) return true; return false; @@ -151,82 +139,72 @@ bool AskPassword(MCONTACT hContact) INT_PTR CALLBACK ChangePasswordDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA); - switch (msg) - { - case WM_INITDIALOG: + switch (msg) { + case WM_INITDIALOG: { hContact = (MCONTACT)lParam; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact); -// RECT rc, rcMe; -// SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); -// GetWindowRect(hwnd, &rcMe); -// SetWindowPos(hwnd, hwnd, -// rc.left+((rc.right-rc.left) - (rcMe.right-rcMe.left))/2, -// rc.top+((rc.bottom-rc.top) - (rcMe.bottom-rcMe.top))/2, -// 0, 0, SWP_NOSIZE|SWP_NOZORDER); + // RECT rc, rcMe; + // SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0); + // GetWindowRect(hwnd, &rcMe); + // SetWindowPos(hwnd, hwnd, + // rc.left+((rc.right-rc.left) - (rcMe.right-rcMe.left))/2, + // rc.top+((rc.bottom-rc.top) - (rcMe.bottom-rcMe.top))/2, + // 0, 0, SWP_NOSIZE|SWP_NOZORDER); SetFocus(GetDlgItem(hwnd, IDC_PASSWORD)); return TRUE; } - case WM_COMMAND: + case WM_COMMAND: { - switch(LOWORD(wParam)) - { - case IDOK: + switch (LOWORD(wParam)) { + case IDOK: { int length = GetWindowTextLengthA(GetDlgItem(hwnd, IDC_PASSWORD)); - char *input = new char[length+1]; - GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD), input, length+1); + char *input = new char[length + 1]; + GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD), input, length + 1); length = GetWindowTextLengthA(GetDlgItem(hwnd, IDC_PASSWORD2)); - char *input2 = new char[length+1]; - GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD2), input2, length+1); + char *input2 = new char[length + 1]; + GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD2), input2, length + 1); length = GetWindowTextLengthA(GetDlgItem(hwnd, IDC_PASSWORD3)); - char *input3 = new char[length+1]; - GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD3), input3, length+1); + char *input3 = new char[length + 1]; + GetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD3), input3, length + 1); - if (lstrcmpA(input2, input3) || !CheckPassword(hContact, input)) - { + if (lstrcmpA(input2, input3) || !CheckPassword(hContact, input)) { MessageBeep(MB_ICONHAND); SetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD), ""); SetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD2), ""); SetWindowTextA(GetDlgItem(hwnd, IDC_PASSWORD3), ""); - } else - { + } + else { SetPassword(hContact, input2); EndDialog(hwnd, 0); } - delete [] input; - delete [] input2; - delete [] input3; - - return TRUE; + delete[] input; + delete[] input2; + delete[] input3; } + return TRUE; - case IDCANCEL: - { - EndDialog(hwnd, 0); - return TRUE; - } + case IDCANCEL: + EndDialog(hwnd, 0); + return TRUE; } break; } - case WM_CLOSE: - { - EndDialog(hwnd, 0); - DestroyWindow(hwnd); - return TRUE; - } + case WM_CLOSE: + EndDialog(hwnd, 0); + DestroyWindow(hwnd); + return TRUE; - case WM_DESTROY: - { - SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); - } + case WM_DESTROY: + SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); } return FALSE; } diff --git a/plugins/NewStory/src/quicklist.h b/plugins/NewStory/src/quicklist.h index 66bb070c6c..ec4471f30c 100644 --- a/plugins/NewStory/src/quicklist.h +++ b/plugins/NewStory/src/quicklist.h @@ -9,7 +9,7 @@ private: }; struct CacheItem { - CacheItem(): item(0), no(0) {} + CacheItem() : item(0), no(0) {} Item *item; int no; }; @@ -29,6 +29,6 @@ public: } ~QuickList() { - delete [] cache; + delete[] cache; } -};
\ No newline at end of file +}; diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index a112f33032..d388a2c9f3 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -83,18 +83,15 @@ TemplateInfo templates[TPL_COUNT] = void LoadTemplates() { - for (int i = 0; i < TPL_COUNT; i++) - { + for (int i = 0; i < TPL_COUNT; i++) { DBVARIANT dbv = { 0 }; db_get_ws(0, MODULENAME, templates[i].setting, &dbv); if (templates[i].value) free(templates[i].value); - if (dbv.pwszVal) - { + if (dbv.pwszVal) { templates[i].value = _tcsdup(dbv.pwszVal); } - else - { + else { templates[i].value = 0; } db_free(&dbv); @@ -115,33 +112,27 @@ TCHAR *TplFormatStringEx(int tpl, TCHAR *sztpl, MCONTACT hContact, HistoryArray: int i; TemplateVars vars; - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { vars.del[i] = false; vars.val[i] = 0; } + for (i = 0; i < TemplateInfo::VF_COUNT; i++) if (templates[tpl].vf[i]) templates[tpl].vf[i](VFM_VARS, &vars, hContact, item); TCHAR *buf = (TCHAR *)malloc(sizeof(TCHAR)*(TplMeasureVars(&vars, sztpl) + 1)); TCHAR *bufptr = buf; - for (TCHAR *p = sztpl; *p; p++) - { - if (*p == '%') - { + for (TCHAR *p = sztpl; *p; p++) { + if (*p == '%') { TCHAR *var = TplGetVar(&vars, (char)(p[1] & 0xff)); - if (var) - { + if (var) { lstrcpy(bufptr, var); bufptr += lstrlen(var); } p++; } - else - { - *bufptr++ = *p; - } + else *bufptr++ = *p; } *bufptr = 0; return buf; @@ -157,33 +148,27 @@ TCHAR *TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData *item) int i; TemplateVars vars; - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { vars.del[i] = false; vars.val[i] = 0; } + for (i = 0; i < TemplateInfo::VF_COUNT; i++) if (templates[tpl].vf[i]) templates[tpl].vf[i](VFM_VARS, &vars, hContact, item); TCHAR *buf = (TCHAR *)malloc(sizeof(TCHAR)*(TplMeasureVars(&vars, templates[tpl].value) + 1)); TCHAR *bufptr = buf; - for (TCHAR *p = templates[tpl].value; *p; p++) - { - if (*p == '%') - { + for (TCHAR *p = templates[tpl].value; *p; p++) { + if (*p == '%') { TCHAR *var = TplGetVar(&vars, (char)(p[1] & 0xff)); - if (var) - { + if (var) { lstrcpy(bufptr, var); bufptr += lstrlen(var); } p++; } - else - { - *bufptr++ = *p; - } + else *bufptr++ = *p; } *bufptr = 0; return buf; @@ -192,8 +177,7 @@ TCHAR *TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData *item) // Variable management void TplInitVars(TemplateVars *vars) { - for (int i = 0; i < 256; i++) - { + for (int i = 0; i < 256; i++) { vars->val[i] = 0; vars->del[i] = false; } @@ -202,8 +186,7 @@ void TplInitVars(TemplateVars *vars) void TplCleanVars(TemplateVars *vars) { for (int i = 0; i < 256; i++) - if (vars->val[i] && vars->del[i]) - { + if (vars->val[i] && vars->del[i]) { free(vars->val[i]); vars->val[i] = 0; vars->del[i] = false; @@ -226,18 +209,13 @@ __forceinline void TplSetVar(TemplateVars *vars, char id, TCHAR *v, bool d) int TplMeasureVars(TemplateVars *vars, TCHAR *str) { int res = 0; - for (TCHAR *p = str; *p; p++) - { - if (*p == '%') - { + for (TCHAR *p = str; *p; p++) { + if (*p == '%') { TCHAR *var = TplGetVar(vars, (char)(p[1] & 0xff)); if (var) res += lstrlen(var); p++; } - else - { - res++; - } + else res++; } return res; } @@ -291,8 +269,7 @@ void vfEvent(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) TplSetVar(vars, 'N', buff, false); // %I: Icon - switch (item->dbe.eventType) - { + switch (item->dbe.eventType) { case EVENTTYPE_MESSAGE: hIcon = GetIcon(ICO_SENDMSG); break; @@ -315,26 +292,19 @@ void vfEvent(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item) // %i: Direction icon if (item->dbe.flags & DBEF_SENT) - { hIcon = GetIcon(ICO_MSGOUT); - } else - { hIcon = GetIcon(ICO_MSGIN); - } + s = (TCHAR *)calloc(64, sizeof(TCHAR)); wsprintf(s, _T("[$hicon=%d$]"), hIcon); TplSetVar(vars, 'i', s, true); // %D: direction symbol if (item->dbe.flags & DBEF_SENT) - { TplSetVar(vars, 'D', _T("<<"), false); - } else - { TplSetVar(vars, 'D', _T(">>"), false); - } // %t: timestamp TCHAR *buf = (TCHAR *)calloc(100, sizeof(TCHAR)); @@ -457,57 +427,53 @@ void vfOther(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData*) INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static int CurrentTemplate; - switch (msg) - { + switch (msg) { case WM_INITDIALOG: - { CurrentTemplate = -1; - - HTREEITEM hGroup = 0; - HTREEITEM hFirst = 0; - - HIMAGELIST himgTree = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 1, 1); - TreeView_SetImageList(GetDlgItem(hwnd, IDC_TEMPLATES), himgTree, TVSIL_NORMAL); - - ImageList_AddIcon(himgTree, GetIcon(ICO_TPLGROUP)); - - for (int i = 0; i < TPL_COUNT; i++) { - if (!i || lstrcmp(templates[i].group, templates[i - 1].group)) - { - if (hGroup) - TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), hGroup, TVE_EXPAND); + HTREEITEM hGroup = 0; + HTREEITEM hFirst = 0; + + HIMAGELIST himgTree = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 1, 1); + TreeView_SetImageList(GetDlgItem(hwnd, IDC_TEMPLATES), himgTree, TVSIL_NORMAL); + + ImageList_AddIcon(himgTree, GetIcon(ICO_TPLGROUP)); + + for (int i = 0; i < TPL_COUNT; i++) { + if (!i || lstrcmp(templates[i].group, templates[i - 1].group)) { + if (hGroup) + TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), hGroup, TVE_EXPAND); + + TVINSERTSTRUCT tvis; + tvis.hParent = 0; + tvis.hInsertAfter = TVI_LAST; + tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvis.item.state = tvis.item.stateMask = TVIS_BOLD; + tvis.item.iSelectedImage = tvis.item.iImage = 0; + tvis.item.pszText = templates[i].group; + tvis.item.lParam = -1; + hGroup = TreeView_InsertItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvis); + + if (!hFirst) hFirst = hGroup; + } TVINSERTSTRUCT tvis; - tvis.hParent = 0; + tvis.hParent = hGroup; tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvis.item.state = tvis.item.stateMask = TVIS_BOLD; - tvis.item.iSelectedImage = tvis.item.iImage = 0; - tvis.item.pszText = templates[i].group; - tvis.item.lParam = -1; - hGroup = TreeView_InsertItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvis); - - if (!hFirst) hFirst = hGroup; + tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvis.item.pszText = templates[i].title; + tvis.item.iSelectedImage = tvis.item.iImage = + ImageList_AddIcon(himgTree, GetIcon(templates[i].icon)); + tvis.item.lParam = i; + TreeView_InsertItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvis); } - TVINSERTSTRUCT tvis; - tvis.hParent = hGroup; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvis.item.pszText = templates[i].title; - tvis.item.iSelectedImage = tvis.item.iImage = - ImageList_AddIcon(himgTree, GetIcon(templates[i].icon)); - tvis.item.lParam = i; - TreeView_InsertItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvis); - } - - if (hGroup) - TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), hGroup, TVE_EXPAND); - - TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hFirst); - TreeView_EnsureVisible(GetDlgItem(hwnd, IDC_TEMPLATES), hFirst); + if (hGroup) + TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), hGroup, TVE_EXPAND); + TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hFirst); + TreeView_EnsureVisible(GetDlgItem(hwnd, IDC_TEMPLATES), hFirst); + } SendMessage(GetDlgItem(hwnd, IDC_DISCARD), BUTTONSETASFLATBTN, 0, 0); SendMessage(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), BUTTONSETASFLATBTN, 0, 0); SendMessage(GetDlgItem(hwnd, IDC_VARHELP), BUTTONSETASFLATBTN, 0, 0); @@ -521,94 +487,73 @@ INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM SendMessage(GetDlgItem(hwnd, IDC_VARHELP), BM_SETIMAGE, IMAGE_ICON, (LPARAM)GetIcon(ICO_VARHELP)); return TRUE; - } case WM_COMMAND: - switch (LOWORD(wParam)) - { + switch (LOWORD(wParam)) { case IDC_EDITTEMPLATE: - { SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); - } case IDC_UPDATEPREVIEW: - { if (templates[CurrentTemplate].tmpValue) free(templates[CurrentTemplate].tmpValue); - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; - templates[CurrentTemplate].tmpValue = (TCHAR *)malloc(length * sizeof(TCHAR)); - GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue, length); - - HistoryArray::ItemData item; - item.hContact = db_find_first(); - while (item.hContact && !item.hEvent) - { - item.hEvent = db_event_first(item.hContact); - if (!item.hEvent) - item.hContact = db_find_next(item.hContact); - } - if (item.hContact && item.hEvent) { - item.load(ELM_DATA); - TCHAR *preview = TplFormatStringEx(CurrentTemplate, templates[CurrentTemplate].tmpValue, item.hContact, &item); - SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), preview); - // SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), preview); - SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), _T("$hit :)")); - free(preview); - } - else - { - SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), _T("")); - SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), _T("")); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; + templates[CurrentTemplate].tmpValue = (TCHAR *)malloc(length * sizeof(TCHAR)); + GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue, length); + + HistoryArray::ItemData item; + item.hContact = db_find_first(); + while (item.hContact && !item.hEvent) { + item.hEvent = db_event_first(item.hContact); + if (!item.hEvent) + item.hContact = db_find_next(item.hContact); + } + + if (item.hContact && item.hEvent) { + item.load(ELM_DATA); + TCHAR *preview = TplFormatStringEx(CurrentTemplate, templates[CurrentTemplate].tmpValue, item.hContact, &item); + SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), preview); + // SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), preview); + SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), _T("$hit :)")); + free(preview); + } + else { + SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), _T("")); + SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), _T("")); + } } break; - } case IDC_DISCARD: - { if (templates[CurrentTemplate].tmpValue) free(templates[CurrentTemplate].tmpValue); templates[CurrentTemplate].tmpValue = 0; if (templates[CurrentTemplate].value) - { SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].value); - } else - { SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].defvalue); - } + PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0); break; } - } break; case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) - { + switch (((LPNMHDR)lParam)->idFrom) { case 0: - { - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case PSN_RESET: - { - for (int i = 0; i < TPL_COUNT; i++) - { - if (templates[i].tmpValue) - { + for (int i = 0; i < TPL_COUNT; i++) { + if (templates[i].tmpValue) { if (templates[i].tmpValue) free(templates[i].tmpValue); } } return TRUE; - } case PSN_APPLY: - { - for (int i = 0; i < TPL_COUNT; i++) - { - if (templates[i].tmpValue) - { + for (int i = 0; i < TPL_COUNT; i++) { + if (templates[i].tmpValue) { if (templates[i].value) free(templates[i].value); templates[i].value = templates[i].tmpValue; @@ -618,102 +563,85 @@ INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM SaveTemplates(); return TRUE; } - } break; - } case IDC_TEMPLATES: - { - switch (((LPNMHDR)lParam)->code) - { + switch (((LPNMHDR)lParam)->code) { case TVN_SELCHANGED: case TVN_SELCHANGING: - { - LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam; - - TVITEM tvi; - tvi.hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_TEMPLATES)); - tvi.mask = TVIF_PARAM; - TreeView_GetItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvi); - - if ((tvi.lParam < 0) || (tvi.lParam >= TPL_COUNT)) { - EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), FALSE); - /* HTREEITEM hItem = TreeView_GetChild(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem); - if (hItem) - { - TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem, TVE_EXPAND); - TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hItem); - }*/ - break; - } - else - { - EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), TRUE); - } + LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam; + + TVITEM tvi; + tvi.hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_TEMPLATES)); + tvi.mask = TVIF_PARAM; + TreeView_GetItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvi); + + if ((tvi.lParam < 0) || (tvi.lParam >= TPL_COUNT)) { + EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), FALSE); + /* HTREEITEM hItem = TreeView_GetChild(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem); + if (hItem) + { + TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem, TVE_EXPAND); + TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hItem); + }*/ + break; + } + else { + EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), TRUE); + } - if ((lpnmtv->itemOld.mask&TVIF_HANDLE) && lpnmtv->itemOld.hItem && (lpnmtv->itemOld.hItem != lpnmtv->itemNew.hItem) && (lpnmtv->itemOld.lParam >= 0) && (lpnmtv->itemOld.lParam < TPL_COUNT)) - { - if (templates[lpnmtv->itemOld.lParam].tmpValue) - free(templates[lpnmtv->itemOld.lParam].tmpValue); - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; - templates[lpnmtv->itemOld.lParam].tmpValue = (TCHAR *)malloc(length * sizeof(TCHAR)); - GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[lpnmtv->itemOld.lParam].tmpValue, length); - } + if ((lpnmtv->itemOld.mask&TVIF_HANDLE) && lpnmtv->itemOld.hItem && (lpnmtv->itemOld.hItem != lpnmtv->itemNew.hItem) && (lpnmtv->itemOld.lParam >= 0) && (lpnmtv->itemOld.lParam < TPL_COUNT)) { + if (templates[lpnmtv->itemOld.lParam].tmpValue) + free(templates[lpnmtv->itemOld.lParam].tmpValue); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; + templates[lpnmtv->itemOld.lParam].tmpValue = (TCHAR *)malloc(length * sizeof(TCHAR)); + GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[lpnmtv->itemOld.lParam].tmpValue, length); + } - CurrentTemplate = tvi.lParam; + CurrentTemplate = tvi.lParam; - if (templates[CurrentTemplate].tmpValue) - { - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue); - } - else - if (templates[CurrentTemplate].value) - { + if (templates[CurrentTemplate].tmpValue) + SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue); + else if (templates[CurrentTemplate].value) SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].value); - } else - { SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].defvalue); - } - - PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0); + PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0); + } break; - } + case TVN_KEYDOWN: case NM_CLICK: - { SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); break; - } - /* - { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); - if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) - if(hti.flags&TVHT_ONITEMSTATEICON) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - } - */ + /* + { + TVHITTESTINFO hti; + hti.pt.x = (short)LOWORD(GetMessagePos()); + hti.pt.y = (short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); + if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) + if(hti.flags&TVHT_ONITEMSTATEICON) + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + } + */ } break; } - } break; } return FALSE; diff --git a/plugins/NewStory/src/templates.h b/plugins/NewStory/src/templates.h index d2235b2c2c..95cbe8f8e9 100644 --- a/plugins/NewStory/src/templates.h +++ b/plugins/NewStory/src/templates.h @@ -19,11 +19,11 @@ struct VFArgs DBEVENTINFO *event; }; */ -typedef void (* VarFunc)(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData *item); +typedef void(*VarFunc)(int mode, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData *item); struct TemplateInfo { - enum { VF_COUNT = 5 }; + enum { VF_COUNT = 5 }; char *setting; TCHAR *group; diff --git a/plugins/NewStory/src/utils.cpp b/plugins/NewStory/src/utils.cpp index 96e7525e19..eb6b405d35 100644 --- a/plugins/NewStory/src/utils.cpp +++ b/plugins/NewStory/src/utils.cpp @@ -9,11 +9,11 @@ DWORD toggleBit(DWORD dw, DWORD bit) bool CheckFilter(TCHAR *buf, TCHAR *filter) { -// MessageBox(0, buf, filter, MB_OK); + // MessageBox(0, buf, filter, MB_OK); int l1 = lstrlen(buf); int l2 = lstrlen(filter); - for (int i = 0; i < l1-l2+1; i++) - if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, buf+i, l2, filter, l2) == CSTR_EQUAL) + for (int i = 0; i < l1 - l2 + 1; i++) + if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, buf + i, l2, filter, l2) == CSTR_EQUAL) return true; return false; } @@ -22,17 +22,17 @@ void CopyText(HWND hwnd, TCHAR *text) { OpenClipboard(hwnd); EmptyClipboard(); - HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(lstrlen(text)+1)); + HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(lstrlen(text) + 1)); TCHAR *s = (TCHAR *)GlobalLock(hMem); lstrcpy(s, text); GlobalUnlock(hMem); #ifdef UNICODE - SetClipboardData(CF_UNICODETEXT, hMem); + SetClipboardData(CF_UNICODETEXT, hMem); #else - SetClipboardData(CF_TEXT, hMem); + SetClipboardData(CF_TEXT, hMem); #endif CloseClipboard(); -// GlobalFree(hMem); + // GlobalFree(hMem); } /*void ExportHistory(HANDLE hContact, char *fnTemplate, char *fn, HWND hwndHistory) @@ -211,17 +211,16 @@ void CopyText(HWND hwnd, TCHAR *text) char *appendString(char *s1, char *s2) { - if (s1) - { + if (s1) { int l1 = lstrlenA(s1); int l2 = lstrlenA(s2); - char *buf = (char *)malloc(l1+l2+1); - _snprintf(buf, l1+l2+1, "%s%s", s1, s2); + char *buf = (char *)malloc(l1 + l2 + 1); + _snprintf(buf, l1 + l2 + 1, "%s%s", s1, s2); free(s1); return buf; - } else - { - char *buf = (char *)malloc(lstrlenA(s2)+1); + } + else { + char *buf = (char *)malloc(lstrlenA(s2) + 1); lstrcpyA(buf, s2); return buf; } @@ -229,18 +228,17 @@ char *appendString(char *s1, char *s2) WCHAR *appendString(WCHAR *s1, WCHAR *s2) { - if (s1) - { + if (s1) { int l1 = lstrlenW(s1); int l2 = lstrlenW(s2); - WCHAR *buf = (WCHAR *)malloc(sizeof(WCHAR)*(l1+l2+1)); - _snwprintf(buf, l1+l2+1, L"%s%s", s1, s2); + WCHAR *buf = (WCHAR *)malloc(sizeof(WCHAR)*(l1 + l2 + 1)); + _snwprintf(buf, l1 + l2 + 1, L"%s%s", s1, s2); free(s1); return buf; - } else - { - WCHAR *buf = (WCHAR *)malloc(sizeof(WCHAR)*(lstrlenW(s2)+1)); + } + else { + WCHAR *buf = (WCHAR *)malloc(sizeof(WCHAR)*(lstrlenW(s2) + 1)); lstrcpyW(buf, s2); return buf; } -}
\ No newline at end of file +} |