diff options
-rw-r--r-- | plugins/NewStory/src/calendartool.cpp | 32 | ||||
-rw-r--r-- | plugins/NewStory/src/fonts.cpp | 10 | ||||
-rw-r--r-- | plugins/NewStory/src/fonts.h | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/history.cpp | 550 | ||||
-rw-r--r-- | plugins/NewStory/src/history.h | 4 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 72 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 54 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 680 | ||||
-rw-r--r-- | plugins/NewStory/src/options.cpp | 106 | ||||
-rw-r--r-- | plugins/NewStory/src/quicklist.h | 8 | ||||
-rw-r--r-- | plugins/NewStory/src/stdafx.h | 10 | ||||
-rw-r--r-- | plugins/NewStory/src/templates.h | 20 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.cpp | 44 | ||||
-rw-r--r-- | plugins/NewStory/src/utils.h | 21 |
14 files changed, 799 insertions, 816 deletions
diff --git a/plugins/NewStory/src/calendartool.cpp b/plugins/NewStory/src/calendartool.cpp index 3a44db032a..dd2578d33a 100644 --- a/plugins/NewStory/src/calendartool.cpp +++ b/plugins/NewStory/src/calendartool.cpp @@ -7,10 +7,10 @@ struct CalendarToolData INT_PTR CALLBACK CalendarToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - CalendarToolData *data = (CalendarToolData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + CalendarToolData* data = (CalendarToolData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: - data = (CalendarToolData *)lParam; + data = (CalendarToolData*)lParam; SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data); // This causes ALL miranda dialogs to have drop-shadow enabled. That's bad =( @@ -36,20 +36,20 @@ INT_PTR CALLBACK CalendarToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; case WM_NOTIFY: - { - LPNMHDR hdr = (LPNMHDR)lParam; - 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; - tm_sel.tm_isdst = 1; - tm_sel.tm_mday = lpnmsc->stSelStart.wDay; - tm_sel.tm_mon = lpnmsc->stSelStart.wMonth - 1; - tm_sel.tm_year = lpnmsc->stSelStart.wYear - 1900; - EndDialog(hwnd, mktime(&tm_sel)); - } - return TRUE; + { + LPNMHDR hdr = (LPNMHDR)lParam; + 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; + tm_sel.tm_isdst = 1; + tm_sel.tm_mday = lpnmsc->stSelStart.wDay; + tm_sel.tm_mon = lpnmsc->stSelStart.wMonth - 1; + tm_sel.tm_year = lpnmsc->stSelStart.wYear - 1900; + EndDialog(hwnd, mktime(&tm_sel)); } + return TRUE; + } case WM_CLOSE: DestroyWindow(hwnd); @@ -65,7 +65,7 @@ INT_PTR CALLBACK CalendarToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM time_t CalendarTool_Show(HWND hwnd, int x, int y) { - CalendarToolData *data = new CalendarToolData; + CalendarToolData* data = new CalendarToolData; data->x = x; data->y = y; return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CALENDARTOOL), hwnd, CalendarToolDlgProc, (LPARAM)data); diff --git a/plugins/NewStory/src/fonts.cpp b/plugins/NewStory/src/fonts.cpp index 272a89723e..d3756b995c 100644 --- a/plugins/NewStory/src/fonts.cpp +++ b/plugins/NewStory/src/fonts.cpp @@ -33,10 +33,10 @@ MyFontID fonts[] = int evtFontsChanged(WPARAM, LPARAM) { - for (auto &it : colors) + for (auto& it : colors) it.cl = Colour_Get(MODULENAME, it.szName); - for (auto &it : fonts) { + for (auto& it : fonts) { it.cl = (COLORREF)Font_Get(MODULENAME, it.szName, &it.lf); DeleteObject(it.hfnt); @@ -58,7 +58,7 @@ void InitFonts() strncpy_s(cid.group, MODULENAME, _TRUNCATE); strncpy_s(cid.dbSettingsGroup, MODULENAME, _TRUNCATE); - for (auto &it : colors) { + for (auto& it : colors) { cid.order = int(&it - colors); strncpy_s(cid.name, it.szName, _TRUNCATE); strncpy_s(cid.setting, it.szSetting, _TRUNCATE); @@ -71,7 +71,7 @@ void InitFonts() strncpy_s(fontid.group, MODULENAME, _TRUNCATE); strncpy_s(fontid.dbSettingsGroup, MODULENAME, _TRUNCATE); - for (auto &it : fonts) { + for (auto& it : fonts) { fontid.order = int(&it - fonts); strncpy_s(fontid.name, it.szName, _TRUNCATE); strncpy_s(fontid.setting, it.szSetting, _TRUNCATE); @@ -84,6 +84,6 @@ void InitFonts() void DestroyFonts() { - for (auto &it : fonts) + for (auto& it : fonts) DeleteObject(it.hfnt); } diff --git a/plugins/NewStory/src/fonts.h b/plugins/NewStory/src/fonts.h index 4718aacb72..6003c01bfb 100644 --- a/plugins/NewStory/src/fonts.h +++ b/plugins/NewStory/src/fonts.h @@ -19,7 +19,7 @@ enum struct MyColourID { - const char *szName, *szSetting; + const char* szName, * szSetting; COLORREF defaultValue, cl; }; @@ -43,7 +43,7 @@ enum struct MyFontID { - const char *szName, *szSetting; + const char* szName, * szSetting; COLORREF cl; LOGFONTA lf; diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp index 905d61602c..7fe96e8ed1 100644 --- a/plugins/NewStory/src/history.cpp +++ b/plugins/NewStory/src/history.cpp @@ -6,9 +6,9 @@ /* for the date picker: - case WM_ACTIVATE: - if (wParam == WA_INACTIVE) PostMessage(m_hwndDialog, WM_CLOSE, 0, 0); - break; + case WM_ACTIVATE: + if (wParam == WA_INACTIVE) PostMessage(m_hwndDialog, WM_CLOSE, 0, 0); + break; */ #include "stdafx.h" @@ -122,7 +122,7 @@ struct WindowData InfoBarEvents ibMessages, ibFiles, ibUrls, ibTotal; }; -void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents *ib) +void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents* ib) { hDwp = DeferWindowPos(hDwp, ib->hwndIco, 0, x, y, 16, 16, SWP_NOZORDER); @@ -141,7 +141,7 @@ void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents *ib) } -void ShowHideControls(HWND hwnd, WindowData *data) +void ShowHideControls(HWND hwnd, WindowData* data) { int cmd; @@ -183,7 +183,7 @@ void ShowHideControls(HWND hwnd, WindowData *data) ShowWindow(data->hwndSearchText, cmd); } -void LayoutHistoryWnd(HWND hwnd, WindowData *data) +void LayoutHistoryWnd(HWND hwnd, WindowData* data) { int i; RECT rc; @@ -413,7 +413,7 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara //CallSnappingWindowProc(hwnd, msg, wParam, lParam); - WindowData *data = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); + WindowData* data = (WindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if ((msg >= NSM_FIRST) && (msg < NSM_LAST)) { int result = SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), msg, wParam, lParam); @@ -423,182 +423,182 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara switch (msg) { case WM_INITDIALOG: - { - data = new WindowData; - data->hContact = (MCONTACT)lParam; - data->disableTimeTreeChange = false; - data->showFlags = db_get_w(data->hContact, MODULENAME, "showFlags", 0x7f); - data->lastYear = data->lastMonth = data->lastDay = -1; - data->hLastYear = data->hLastMonth = data->hLastDay = 0; - - data->wndOptions = 0; - - // get handles - data->hwndBtnToolbar[TBTN_USERINFO] = GetDlgItem(hwnd, IDC_USERINFO); - data->hwndBtnToolbar[TBTN_USERMENU] = GetDlgItem(hwnd, IDC_USERMENU); - data->hwndBtnToolbar[TBTN_MESSAGE] = GetDlgItem(hwnd, IDC_MESSAGE); - data->hwndBtnToolbar[TBTN_SEARCH] = GetDlgItem(hwnd, IDC_SEARCH); - data->hwndBtnToolbar[TBTN_COPY] = GetDlgItem(hwnd, IDC_COPY); - data->hwndBtnToolbar[TBTN_EXPORT] = GetDlgItem(hwnd, IDC_EXPORT); - data->hwndBtnToolbar[TBTN_LOGOPTIONS] = GetDlgItem(hwnd, IDC_LOGOPTIONS); - data->hwndBtnToolbar[TBTN_FILTER] = GetDlgItem(hwnd, IDC_FILTER); - data->hwndBtnToolbar[TBTN_DATEPOPUP] = GetDlgItem(hwnd, IDC_DATEPOPUP); - data->hwndBtnToolbar[TBTN_CLOSE] = GetDlgItem(hwnd, IDC_CLOSE); - data->hwndLog = GetDlgItem(hwnd, IDC_ITEMS2); - data->hwndBtnCloseSearch = GetDlgItem(hwnd, IDC_SEARCHICON); - data->hwndBtnFindPrev = GetDlgItem(hwnd, IDC_FINDPREV); - data->hwndBtnFindNext = GetDlgItem(hwnd, IDC_FINDNEXT); - data->hwndSearchText = GetDlgItem(hwnd, IDC_SEARCHTEXT); - data->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwnd, NULL, g_plugin.getInst(), NULL); - SendMessage(data->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0); - - // 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->hwndDateFrom = GetDlgItem(hwnd, IDC_DATE_FROM); - data->hwndDateTo = GetDlgItem(hwnd, IDC_DATE_TO); - - data->ibMessages.hwndIco = GetDlgItem(hwnd, IDC_ICO_MESSAGES); - data->ibMessages.hwndTxt = GetDlgItem(hwnd, IDC_TXT_MESSAGES); - data->ibMessages.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_MESSAGES_IN); - SendMessage(data->ibMessages.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); - SendMessage(data->ibMessages.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); - SendMessage(data->ibMessages.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); - data->ibMessages.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_MESSAGES_IN); - data->ibMessages.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_MESSAGES_OUT); - SendMessage(data->ibMessages.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); - SendMessage(data->ibMessages.hwndIcoOut, BUTTONSETASPUSHBTN, 0, 0); - SendMessage(data->ibMessages.hwndIcoOut, BM_SETCHECK, BST_CHECKED, 0); - data->ibMessages.hwndTxtOut = GetDlgItem(hwnd, IDC_TXT_MESSAGES_OUT); - - data->ibFiles.hwndIco = GetDlgItem(hwnd, IDC_ICO_FILES); - data->ibFiles.hwndTxt = GetDlgItem(hwnd, IDC_TXT_FILES); - data->ibFiles.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_FILES_IN); - SendMessage(data->ibFiles.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); - SendMessage(data->ibFiles.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); - SendMessage(data->ibFiles.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); - data->ibFiles.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_FILES_IN); - data->ibFiles.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_FILES_OUT); - SendMessage(data->ibFiles.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); - SendMessage(data->ibFiles.hwndIcoOut, BUTTONSETASPUSHBTN, 0, 0); - SendMessage(data->ibFiles.hwndIcoOut, BM_SETCHECK, BST_CHECKED, 0); - data->ibFiles.hwndTxtOut = GetDlgItem(hwnd, IDC_TXT_FILES_OUT); - - data->ibUrls.hwndIco = GetDlgItem(hwnd, IDC_ICO_URLS); - data->ibUrls.hwndTxt = GetDlgItem(hwnd, IDC_TXT_URLS); - data->ibUrls.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_URLS_IN); - SendMessage(data->ibUrls.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); - SendMessage(data->ibUrls.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); - SendMessage(data->ibUrls.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); - data->ibUrls.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_URLS_IN); - data->ibUrls.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_URLS_OUT); - SendMessage(data->ibUrls.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); - SendMessage(data->ibUrls.hwndIcoOut, BUTTONSETASPUSHBTN, 0, 0); - SendMessage(data->ibUrls.hwndIcoOut, BM_SETCHECK, BST_CHECKED, 0); - data->ibUrls.hwndTxtOut = GetDlgItem(hwnd, IDC_TXT_URLS_OUT); - - data->ibTotal.hwndIco = GetDlgItem(hwnd, IDC_ICO_TOTAL); - data->ibTotal.hwndTxt = GetDlgItem(hwnd, IDC_TXT_TOTAL); - data->ibTotal.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_TOTAL_IN); - SendMessage(data->ibTotal.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); - SendMessage(data->ibTotal.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); - SendMessage(data->ibTotal.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); - data->ibTotal.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_TOTAL_IN); - data->ibTotal.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_TOTAL_OUT); - SendMessage(data->ibTotal.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); - 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)); - //CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)data->hMenu, 0); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_INCOMING, - data->showFlags&HIST_SHOW_IN ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OUTGOING, - data->showFlags&HIST_SHOW_OUT ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_MESSAGES, - data->showFlags&HIST_SHOW_MSGS ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_FILES, - data->showFlags&HIST_SHOW_FILES ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_URLS, - data->showFlags&HIST_SHOW_URLS ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_STATUS, - data->showFlags&HIST_SHOW_STATUS ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OTHER, - data->showFlags&HIST_SHOW_OTHER ? MF_CHECKED : MF_UNCHECKED); - 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); - - // Ask for layout - PostMessage(hwnd, WM_SIZE, 0, 0); + { + data = new WindowData; + data->hContact = (MCONTACT)lParam; + data->disableTimeTreeChange = false; + data->showFlags = db_get_w(data->hContact, MODULENAME, "showFlags", 0x7f); + data->lastYear = data->lastMonth = data->lastDay = -1; + data->hLastYear = data->hLastMonth = data->hLastDay = 0; + + data->wndOptions = 0; + + // get handles + data->hwndBtnToolbar[TBTN_USERINFO] = GetDlgItem(hwnd, IDC_USERINFO); + data->hwndBtnToolbar[TBTN_USERMENU] = GetDlgItem(hwnd, IDC_USERMENU); + data->hwndBtnToolbar[TBTN_MESSAGE] = GetDlgItem(hwnd, IDC_MESSAGE); + data->hwndBtnToolbar[TBTN_SEARCH] = GetDlgItem(hwnd, IDC_SEARCH); + data->hwndBtnToolbar[TBTN_COPY] = GetDlgItem(hwnd, IDC_COPY); + data->hwndBtnToolbar[TBTN_EXPORT] = GetDlgItem(hwnd, IDC_EXPORT); + data->hwndBtnToolbar[TBTN_LOGOPTIONS] = GetDlgItem(hwnd, IDC_LOGOPTIONS); + data->hwndBtnToolbar[TBTN_FILTER] = GetDlgItem(hwnd, IDC_FILTER); + data->hwndBtnToolbar[TBTN_DATEPOPUP] = GetDlgItem(hwnd, IDC_DATEPOPUP); + data->hwndBtnToolbar[TBTN_CLOSE] = GetDlgItem(hwnd, IDC_CLOSE); + data->hwndLog = GetDlgItem(hwnd, IDC_ITEMS2); + data->hwndBtnCloseSearch = GetDlgItem(hwnd, IDC_SEARCHICON); + data->hwndBtnFindPrev = GetDlgItem(hwnd, IDC_FINDPREV); + data->hwndBtnFindNext = GetDlgItem(hwnd, IDC_FINDNEXT); + data->hwndSearchText = GetDlgItem(hwnd, IDC_SEARCHTEXT); + data->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, hwnd, NULL, g_plugin.getInst(), NULL); + SendMessage(data->hwndStatus, SB_SETMINHEIGHT, GetSystemMetrics(SM_CYSMICON), 0); + + // 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->hwndDateFrom = GetDlgItem(hwnd, IDC_DATE_FROM); + data->hwndDateTo = GetDlgItem(hwnd, IDC_DATE_TO); + + data->ibMessages.hwndIco = GetDlgItem(hwnd, IDC_ICO_MESSAGES); + data->ibMessages.hwndTxt = GetDlgItem(hwnd, IDC_TXT_MESSAGES); + data->ibMessages.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_MESSAGES_IN); + SendMessage(data->ibMessages.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); + SendMessage(data->ibMessages.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); + SendMessage(data->ibMessages.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); + data->ibMessages.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_MESSAGES_IN); + data->ibMessages.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_MESSAGES_OUT); + SendMessage(data->ibMessages.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); + SendMessage(data->ibMessages.hwndIcoOut, BUTTONSETASPUSHBTN, 0, 0); + SendMessage(data->ibMessages.hwndIcoOut, BM_SETCHECK, BST_CHECKED, 0); + data->ibMessages.hwndTxtOut = GetDlgItem(hwnd, IDC_TXT_MESSAGES_OUT); + + data->ibFiles.hwndIco = GetDlgItem(hwnd, IDC_ICO_FILES); + data->ibFiles.hwndTxt = GetDlgItem(hwnd, IDC_TXT_FILES); + data->ibFiles.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_FILES_IN); + SendMessage(data->ibFiles.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); + SendMessage(data->ibFiles.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); + SendMessage(data->ibFiles.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); + data->ibFiles.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_FILES_IN); + data->ibFiles.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_FILES_OUT); + SendMessage(data->ibFiles.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); + SendMessage(data->ibFiles.hwndIcoOut, BUTTONSETASPUSHBTN, 0, 0); + SendMessage(data->ibFiles.hwndIcoOut, BM_SETCHECK, BST_CHECKED, 0); + data->ibFiles.hwndTxtOut = GetDlgItem(hwnd, IDC_TXT_FILES_OUT); + + data->ibUrls.hwndIco = GetDlgItem(hwnd, IDC_ICO_URLS); + data->ibUrls.hwndTxt = GetDlgItem(hwnd, IDC_TXT_URLS); + data->ibUrls.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_URLS_IN); + SendMessage(data->ibUrls.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); + SendMessage(data->ibUrls.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); + SendMessage(data->ibUrls.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); + data->ibUrls.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_URLS_IN); + data->ibUrls.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_URLS_OUT); + SendMessage(data->ibUrls.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); + SendMessage(data->ibUrls.hwndIcoOut, BUTTONSETASPUSHBTN, 0, 0); + SendMessage(data->ibUrls.hwndIcoOut, BM_SETCHECK, BST_CHECKED, 0); + data->ibUrls.hwndTxtOut = GetDlgItem(hwnd, IDC_TXT_URLS_OUT); + + data->ibTotal.hwndIco = GetDlgItem(hwnd, IDC_ICO_TOTAL); + data->ibTotal.hwndTxt = GetDlgItem(hwnd, IDC_TXT_TOTAL); + data->ibTotal.hwndIcoIn = GetDlgItem(hwnd, IDC_ICO_TOTAL_IN); + SendMessage(data->ibTotal.hwndIcoIn, BUTTONSETASFLATBTN, 0, 0); + SendMessage(data->ibTotal.hwndIcoIn, BUTTONSETASPUSHBTN, 0, 0); + SendMessage(data->ibTotal.hwndIcoIn, BM_SETCHECK, BST_CHECKED, 0); + data->ibTotal.hwndTxtIn = GetDlgItem(hwnd, IDC_TXT_TOTAL_IN); + data->ibTotal.hwndIcoOut = GetDlgItem(hwnd, IDC_ICO_TOTAL_OUT); + SendMessage(data->ibTotal.hwndIcoOut, BUTTONSETASFLATBTN, 0, 0); + 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)); + //CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)data->hMenu, 0); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_INCOMING, + data->showFlags & HIST_SHOW_IN ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OUTGOING, + data->showFlags & HIST_SHOW_OUT ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_MESSAGES, + data->showFlags & HIST_SHOW_MSGS ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_FILES, + data->showFlags & HIST_SHOW_FILES ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_URLS, + data->showFlags & HIST_SHOW_URLS ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_STATUS, + data->showFlags & HIST_SHOW_STATUS ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_FILTER_OTHER, + data->showFlags & HIST_SHOW_OTHER ? MF_CHECKED : MF_UNCHECKED); + 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); + + // 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_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_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_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)) { + wchar_t* title = TplFormatString(TPL_TITLE, data->hContact, 0); + SetWindowText(hwnd, title); + mir_free(title); + } + else { + if (data->hContact == INVALID_CONTACT_ID) + SetWindowText(hwnd, TranslateT("Newstory Search Results")); + else + SetWindowText(hwnd, TranslateT("System Newstory")); + } - 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_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_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)) { - wchar_t *title = TplFormatString(TPL_TITLE, data->hContact, 0); - SetWindowText(hwnd, title); - mir_free(title); - } - 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) + PostMessage(GetDlgItem(hwnd, IDC_ITEMS2), WM_USER, (WPARAM)data->hContact, 0); - if (data->hContact != INVALID_CONTACT_ID) - PostMessage(GetDlgItem(hwnd, IDC_ITEMS2), WM_USER, (WPARAM)data->hContact, 0); + SendMessage(hwnd, UM_UPDATEICONS, 0, 0); + SetFocus(GetDlgItem(hwnd, IDC_ITEMS2)); - SendMessage(hwnd, UM_UPDATEICONS, 0, 0); - SetFocus(GetDlgItem(hwnd, IDC_ITEMS2)); + 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"); - 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); - if (left - right && top - bottom) - MoveWindow(hwnd, left, top, right - left, bottom - top, TRUE); + ShowHideControls(hwnd, data); - ShowHideControls(hwnd, data); - - return TRUE; - } + return TRUE; + } case UM_UPDATEICONS: SendMessage(hwnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_plugin.getIcon(ICO_NEWSTORY)); @@ -701,53 +701,53 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return TRUE; case WM_DRAWITEM: - { - LPDRAWITEMSTRUCT lpdis; - lpdis = (LPDRAWITEMSTRUCT)lParam; + { + LPDRAWITEMSTRUCT lpdis; + lpdis = (LPDRAWITEMSTRUCT)lParam; - if (lpdis->CtlType == ODT_MENU) - return Menu_DrawItem(lParam); + if (lpdis->CtlType == ODT_MENU) + return Menu_DrawItem(lParam); - if (lpdis->itemID == -1) - return FALSE; + if (lpdis->itemID == -1) + return FALSE; - return TRUE; - } + return TRUE; + } case WM_NOTIFY: + { + LPNMHDR hdr = (LPNMHDR)lParam; + switch (hdr->idFrom) { + case IDC_TIMETREE: { - LPNMHDR hdr = (LPNMHDR)lParam; - switch (hdr->idFrom) { - case IDC_TIMETREE: - { - switch (hdr->code) { - case TVN_SELCHANGED: - { - 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)); - } - break; - } - } - break; + switch (hdr->code) { + case TVN_SELCHANGED: + { + 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)); } + break; + } } + 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 IDCANCEL: case IDC_CLOSE: @@ -763,47 +763,47 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; case IDC_DATEPOPUP: - { - 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; - } + { + 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_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; - } + { + 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_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; + { + 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 ID_LOGOPTIONS_TEMPLATES: - g_plugin.openOptions(nullptr, L"Newstory", L"Templates"); - break; - } - PostMessage(hwnd, WM_SIZE, 0, 0); + case ID_LOGOPTIONS_TEMPLATES: + g_plugin.openOptions(nullptr, L"Newstory", L"Templates"); break; } + PostMessage(hwnd, WM_SIZE, 0, 0); + break; + } case IDC_SEARCH: if (data->wndOptions & WND_OPT_SEARCHBAR) @@ -896,50 +896,50 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if (doFilter) PostMessage(hwnd, UM_REBUILDLIST, 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)) + 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_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; - wchar_t *buf = new wchar_t[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; - } - break; + { + int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1; + wchar_t* buf = new wchar_t[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; + } + break; case IDOK: case IDC_FINDNEXT: - { - int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1; - wchar_t *buf = new wchar_t[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; + { + int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1; + wchar_t* buf = new wchar_t[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); diff --git a/plugins/NewStory/src/history.h b/plugins/NewStory/src/history.h index 8d699bcbfe..5b658c733e 100644 --- a/plugins/NewStory/src/history.h +++ b/plugins/NewStory/src/history.h @@ -5,7 +5,7 @@ enum { - UM_LOADCONTACT = WM_USER+1, + UM_LOADCONTACT = WM_USER + 1, UM_REBUILDLIST, UM_FILTERLIST, @@ -25,7 +25,7 @@ enum UM_GETEVENTTEXT, UM_GETEVENTCONTACT, UM_GETEVENTHANDLE, -// UM_GETEVENTDATA, + // UM_GETEVENTDATA, UM_JUMP2TIME }; diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index 0d8c870c6c..86946e6a16 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -27,50 +27,50 @@ bool HistoryArray::ItemData::load(EventLoadMode mode) switch (dbe.eventType) { case EVENTTYPE_STATUSCHANGE: case EVENTTYPE_MESSAGE: - { - atext = (char *)dbe.pBlob; - atext_del = false; - aLength = mir_strlen(atext); - if (dbe.cbBlob > (DWORD)aLength + 1) { - wtext = (wchar_t *)(dbe.pBlob + aLength + 1); - wtext_del = false; - } - break; + { + atext = (char*)dbe.pBlob; + atext_del = false; + aLength = mir_strlen(atext); + if (dbe.cbBlob > (DWORD)aLength + 1) { + wtext = (wchar_t*)(dbe.pBlob + aLength + 1); + wtext_del = false; } + break; + } case EVENTTYPE_AUTHREQUEST: - { - atext = new char[512]; - atext_del = true; - if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { - mir_snprintf(atext, 512, ("%s requested authorization"), dbe.pBlob + 8); - } - else { - mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD *)(dbe.pBlob)); - } - aLength = mir_strlen(atext); - break; + { + atext = new char[512]; + atext_del = true; + if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { + mir_snprintf(atext, 512, ("%s requested authorization"), dbe.pBlob + 8); } + else { + mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD*)(dbe.pBlob)); + } + aLength = mir_strlen(atext); + break; + } case EVENTTYPE_ADDED: - { - atext = new char[512]; - atext_del = true; - if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { - mir_snprintf(atext, 512, ("%s added you to the contact list"), dbe.pBlob + 8); - } - else { - mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD *)(dbe.pBlob)); - } - aLength = mir_strlen(atext); - break; + { + atext = new char[512]; + atext_del = true; + if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) { + mir_snprintf(atext, 512, ("%s added you to the contact list"), dbe.pBlob + 8); + } + else { + mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD*)(dbe.pBlob)); } + aLength = mir_strlen(atext); + break; + } } if (atext && !wtext) { #ifdef UNICODE int bufSize = MultiByteToWideChar(CP_ACP, 0, atext, aLength + 1, 0, 0); - wtext = new WCHAR[bufSize + 1]; + wtext = new wchar_t[bufSize + 1]; MultiByteToWideChar(CP_ACP, 0, atext, aLength + 1, wtext, bufSize); wtext_del = true; #else @@ -119,7 +119,7 @@ HistoryArray::~HistoryArray() bool HistoryArray::allocateBlock(int count) { - ItemBlock *newBlock = new ItemBlock; + ItemBlock* newBlock = new ItemBlock; newBlock->items = new ItemData[count]; newBlock->count = count; newBlock->prev = tail; @@ -139,7 +139,7 @@ bool HistoryArray::allocateBlock(int count) void HistoryArray::clear() { while (head) { - ItemBlock *next = head->next; + ItemBlock* next = head->next; // for (int i = 0; i < head->count; ++i) // destroyEvent(head->items[i]); delete[] head->items; @@ -195,10 +195,10 @@ bool HistoryArray::preloadEvents(int count) return true; } */ -HistoryArray::ItemData *HistoryArray::get(int id, EventLoadMode mode) +HistoryArray::ItemData* HistoryArray::get(int id, EventLoadMode mode) { int offset = 0; - for (ItemBlock *p = head; p; p = p->next) { + for (ItemBlock* p = head; p; p = p->next) { if (id < offset + p->count) { if (mode != ELM_NOTHING) p->items[id - offset].load(mode); diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 955e63b1b5..9410c686b2 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -41,8 +41,8 @@ public: DBEVENTINFO dbe; bool atext_del = false, wtext_del = false; - char *atext = 0; - WCHAR *wtext = 0; + char* atext = 0; + wchar_t* wtext = 0; HANDLE data = 0; @@ -56,21 +56,21 @@ public: return load(mode); return true; } - inline TCHAR *getTBuf() + inline wchar_t* getTBuf() { loadInline(ELM_DATA); - #ifdef UNICODE +#ifdef UNICODE return wtext; - #else +#else return atext; - #endif +#endif } - inline char *getBuf() + inline char* getBuf() { loadInline(ELM_DATA); return atext; } - inline WCHAR *getWBuf() + inline wchar_t* getWBuf() { loadInline(ELM_DATA); return wtext; @@ -79,9 +79,9 @@ public: struct ItemBlock { - ItemData *items; + ItemData* items; int count; - ItemBlock *prev, *next; + ItemBlock* prev, * next; }; class Filter @@ -98,35 +98,35 @@ public: EVENTTEXT = 0x080, EVENTONLY = 0x100, }; - Filter(WORD aFlags, TCHAR *aText) + Filter(WORD aFlags, wchar_t* aText) { refCount = new int(0); flags = aFlags; - text = new TCHAR[lstrlen(aText) + 1]; - lstrcpy(text, aText); + text = new wchar_t[mir_wstrlen(aText) + 1]; + mir_wstrcpy(text, aText); } - Filter(const Filter &other) + Filter(const Filter& other) { flags = other.flags; refCount = other.refCount; text = other.text; - ++*refCount; + ++* refCount; } - Filter &operator=(const Filter &other) + Filter& operator=(const Filter& other) { flags = other.flags; refCount = other.refCount; text = other.text; - ++*refCount; + ++* refCount; } ~Filter() { - if (!--*refCount) { + if (!-- * refCount) { delete refCount; if (text) delete[] text; } } - inline bool check(ItemData *item) + inline bool check(ItemData* item) { if (!item) return false; if (!(flags & EVENTONLY)) { @@ -165,13 +165,13 @@ public: private: WORD flags; - int *refCount; - TCHAR *text; + int* refCount; + wchar_t* text; }; private: - ItemBlock *head = 0, *tail = 0; - ItemBlock *preBlock = 0; + ItemBlock* head = 0, * tail = 0; + ItemBlock* preBlock = 0; int preIndex = 0; bool allocateBlock(int count); @@ -185,9 +185,9 @@ public: // bool preloadEvents(int count = 10); - ItemData *get(int id, EventLoadMode mode = ELM_NOTHING); - ItemData *operator[] (int id) { return get(id, ELM_DATA); } - ItemData *operator() (int id) { return get(id, ELM_INFO); } + ItemData* get(int id, EventLoadMode mode = ELM_NOTHING); + ItemData* operator[] (int id) { return get(id, ELM_DATA); } + ItemData* operator() (int id) { return get(id, ELM_INFO); } int FindRel(int id, int dir, Filter filter) { @@ -203,7 +203,7 @@ public: int getCount() { int res = 0; - for (ItemBlock *p = head; p; p = p->next) + for (ItemBlock* p = head; p; p = p->next) res += p->count; return res; } diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 7b718e0421..8cdb1f88a0 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -11,7 +11,7 @@ void InitNewstoryControl() WNDCLASS wndclass = {}; wndclass.style = /*CS_HREDRAW | CS_VREDRAW | */CS_DBLCLKS | CS_GLOBALCLASS; wndclass.lpfnWndProc = NewstoryListWndProc; - wndclass.cbWndExtra = sizeof(void *); + wndclass.cbWndExtra = sizeof(void*); wndclass.hInstance = g_plugin.getInst(); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.lpszClassName = _T(NEWSTORYLIST_CLASS); @@ -47,14 +47,14 @@ struct NewstoryListData : public MZeroedObject // return CreateFontIndirect(&lf); //} -static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int scrollPixels); -static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item); -static void FixScrollPosition(HWND hwnd, NewstoryListData *data); -static void RecalcScrollBar(HWND hwnd, NewstoryListData *data); -static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index); -static void EndEditItem(HWND hwnd, NewstoryListData *data); -static int LayoutItem(HWND hwnd, HistoryArray *items, int index); -static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width); +static void ScrollListBy(HWND hwnd, NewstoryListData* data, int scrollItems, int scrollPixels); +static void EnsureVisible(HWND hwnd, NewstoryListData* data, int item); +static void FixScrollPosition(HWND hwnd, NewstoryListData* data); +static void RecalcScrollBar(HWND hwnd, NewstoryListData* data); +static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index); +static void EndEditItem(HWND hwnd, NewstoryListData* data); +static int LayoutItem(HWND hwnd, HistoryArray* items, int index); +static int PaintItem(HDC hdc, HistoryArray* items, int index, int top, int width); // Edit box @@ -63,32 +63,32 @@ static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, L { switch (msg) { case WM_KEYDOWN: + { + switch (wParam) { + case VK_ESCAPE: { - switch (wParam) { - case VK_ESCAPE: - { - EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0)); - return 0; - } - } - break; + EndEditItem(GetParent(hwnd), (NewstoryListData*)GetWindowLongPtr(GetParent(hwnd), 0)); + return 0; } + } + 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; - } - return DLGC_WANTMESSAGE; + { + 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; } - // case WM_KILLFOCUS: - // { - // EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0)); - // return 0; - // } + return DLGC_WANTMESSAGE; + } + // case WM_KILLFOCUS: + // { + // EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0)); + // return 0; + // } } return CallWindowProc(OldEditWndProc, hwnd, msg, wParam, lParam); } @@ -97,7 +97,7 @@ static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, L // WndProc LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - NewstoryListData *data = (NewstoryListData *)GetWindowLongPtr(hwnd, 0); + NewstoryListData* data = (NewstoryListData*)GetWindowLongPtr(hwnd, 0); switch (msg) { case WM_CREATE: @@ -119,156 +119,156 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return data->items.getCount(); 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) { - start ^= end; - end ^= start; - start ^= end; - } - for (int i = start; i <= end; ++i) - data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; - InvalidateRect(hwnd, 0, FALSE); - return 0; + { + 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) + data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; + InvalidateRect(hwnd, 0, FALSE); + return 0; + } 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) { - start ^= end; - end ^= start; - 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) { + 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 { - data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; - } + else { + data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; } - InvalidateRect(hwnd, 0, FALSE); - return 0; } + InvalidateRect(hwnd, 0, FALSE); + return 0; + } 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) { - start ^= end; - end ^= start; - 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)) { + data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; } - int count = data->items.getCount(); - for (int i = 0; i < count; ++i) { - if ((i >= start) && (i <= end)) { - data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED; - } - else { - data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED); - } + else { + data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED); } - InvalidateRect(hwnd, 0, FALSE); - return 0; } + InvalidateRect(hwnd, 0, FALSE); + return 0; + } 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) { - start ^= end; - end ^= start; - start ^= end; - } - for (int i = start; i <= end; ++i) - data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED); - InvalidateRect(hwnd, 0, FALSE); - return 0; + { + 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) + data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED); + InvalidateRect(hwnd, 0, FALSE); + return 0; + } case NSM_ENSUREVISIBLE: EnsureVisible(hwnd, data, wParam); return 0; case NSM_GETITEMFROMPIXEL: - { - RECT rc; - GetClientRect(hwnd, &rc); - int height = rc.bottom - rc.top; - DWORD count = data->items.getCount(); - DWORD current = data->scrollTopItem; - int top = data->scrollTopPixel; - int bottom = top + LayoutItem(hwnd, &data->items, current); - while (top <= height) { - if ((lParam >= top) && (lParam <= bottom)) - return current; - if (++current >= count) - return -1; - top = bottom; - bottom = top + LayoutItem(hwnd, &data->items, current); - } - return -1; + { + RECT rc; + GetClientRect(hwnd, &rc); + int height = rc.bottom - rc.top; + DWORD count = data->items.getCount(); + DWORD current = data->scrollTopItem; + int top = data->scrollTopPixel; + int bottom = top + LayoutItem(hwnd, &data->items, current); + while (top <= height) { + if ((lParam >= top) && (lParam <= bottom)) + return current; + if (++current >= count) + return -1; + top = bottom; + bottom = top + LayoutItem(hwnd, &data->items, current); } + return -1; + } case NSM_SETCARET: - { - if ((wParam >= 0) && (wParam < data->items.getCount())) { - data->caret = wParam; - if (lParam) { - SendMessage(hwnd, NSM_ENSUREVISIBLE, data->caret, 0); - } + { + if ((wParam >= 0) && (wParam < data->items.getCount())) { + data->caret = wParam; + if (lParam) { + SendMessage(hwnd, NSM_ENSUREVISIBLE, data->caret, 0); } } + } case NSM_GETCARET: - { - return data->caret; - } + { + return data->caret; + } case NSM_FINDNEXT: - { - int id = data->items.FindNext(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (TCHAR *)wParam)); - if (id >= 0) { - SendMessage(hwnd, NSM_SELECTITEMS2, id, id); - SendMessage(hwnd, NSM_SETCARET, id, TRUE); - } - return id; + { + int id = data->items.FindNext(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (wchar_t*)wParam)); + if (id >= 0) { + SendMessage(hwnd, NSM_SELECTITEMS2, id, id); + SendMessage(hwnd, NSM_SETCARET, id, TRUE); } + return id; + } case NSM_FINDPREV: - { - int id = data->items.FindPrev(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (TCHAR *)wParam)); - if (id >= 0) { - SendMessage(hwnd, NSM_SELECTITEMS2, id, id); - SendMessage(hwnd, NSM_SETCARET, id, TRUE); - } - return id; + { + int id = data->items.FindPrev(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (wchar_t*)wParam)); + if (id >= 0) { + SendMessage(hwnd, NSM_SELECTITEMS2, id, id); + SendMessage(hwnd, NSM_SETCARET, id, TRUE); } + return id; + } case NSM_COPY: - { - TCHAR *res = 0; - TCHAR *buf; - - int eventCount = data->items.getCount(); - for (int i = 0; i < eventCount; i++) { - HistoryArray::ItemData *item = data->items.get(i, ELM_NOTHING); - if (item->flags & HIF_SELECTED) { - buf = TplFormatString(TPL_COPY_MESSAGE, item->hContact, item); - res = appendString(res, buf); - mir_free(buf); - } + { + wchar_t* res = 0; + wchar_t* buf; + + int eventCount = data->items.getCount(); + for (int i = 0; i < eventCount; i++) { + HistoryArray::ItemData* item = data->items.get(i, ELM_NOTHING); + if (item->flags & HIF_SELECTED) { + buf = TplFormatString(TPL_COPY_MESSAGE, item->hContact, item); + res = appendString(res, buf); + mir_free(buf); } - - CopyText(hwnd, res); - mir_free(res); } - // End of history list control messages + + CopyText(hwnd, res); + mir_free(res); + } + // End of history list control messages case WM_SIZE: InvalidateRect(hwnd, 0, FALSE); break; @@ -277,96 +277,96 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return 1; case WM_PRINTCLIENT: - { - // PaintClc(hwnd, dat, (HDC) wParam, NULL); - break; - } - /* - case WM_NCPAINT: - { - RECT rc; - GetWindowRect(hwnd, &rc); + { + // PaintClc(hwnd, dat, (HDC) wParam, NULL); + break; + } + /* + 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); - } + 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; - hdcWindow = BeginPaint(hwnd, &ps); - - /* 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)) { - RECT rc; - GetClientRect(hwnd, &rc); - - // HDC hdc = hdcWindow; - HDC hdc = CreateCompatibleDC(hdcWindow); - HBITMAP hbmSave = (HBITMAP)SelectObject(hdc, CreateCompatibleBitmap(hdcWindow, rc.right - rc.left, rc.bottom - rc.top)); - - GetClientRect(hwnd, &rc); - int height = rc.bottom - rc.top; - int width = rc.right - rc.left; - int top = data->scrollTopPixel; - int idx = data->scrollTopItem; - while ((top < height) && (idx < data->items.getCount())) - top += PaintItem(hdc, &data->items, idx++, top, width); - - if (top <= height) { - RECT rc2; - SetRect(&rc2, 0, top, width, height); - - HBRUSH hbr; - hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff)); - FillRect(hdc, &rc2, hbr); - DeleteObject(hbr); - } + { + HDC hdcWindow; + PAINTSTRUCT ps; + hdcWindow = BeginPaint(hwnd, &ps); + + /* 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)) { + RECT rc; + GetClientRect(hwnd, &rc); - GetWindowRect(hwnd, &rc); - rc.right -= rc.left; rc.left = 0; - rc.bottom -= rc.top; rc.top = 0; - DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT); + // HDC hdc = hdcWindow; + HDC hdc = CreateCompatibleDC(hdcWindow); + HBITMAP hbmSave = (HBITMAP)SelectObject(hdc, CreateCompatibleBitmap(hdcWindow, rc.right - rc.left, rc.bottom - rc.top)); - BitBlt(hdcWindow, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY); - DeleteObject(SelectObject(hdc, hbmSave)); - DeleteDC(hdc); + GetClientRect(hwnd, &rc); + int height = rc.bottom - rc.top; + int width = rc.right - rc.left; + int top = data->scrollTopPixel; + int idx = data->scrollTopItem; + while ((top < height) && (idx < data->items.getCount())) + top += PaintItem(hdc, &data->items, idx++, top, width); + + if (top <= height) { + RECT rc2; + SetRect(&rc2, 0, top, width, height); + + HBRUSH hbr; + hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff)); + FillRect(hdc, &rc2, hbr); + DeleteObject(hbr); } - EndPaint(hwnd, &ps); + GetWindowRect(hwnd, &rc); + rc.right -= rc.left; rc.left = 0; + rc.bottom -= rc.top; rc.top = 0; + DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT); + + BitBlt(hdcWindow, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY); + DeleteObject(SelectObject(hdc, hbmSave)); + DeleteDC(hdc); } - break; + + EndPaint(hwnd, &ps); + } + break; case WM_SETFOCUS: return 0; case WM_GETDLGCODE: if (lParam) { - MSG *msg2 = (MSG *)lParam; + MSG* msg2 = (MSG*)lParam; if (msg2->message == WM_KEYDOWN) { if (msg2->wParam == VK_TAB) return 0; @@ -383,36 +383,36 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM return DLGC_WANTMESSAGE; case WM_KEYDOWN: - { - switch (wParam) { - case VK_UP: - SendMessage(hwnd, NSM_SELECTITEMS2, data->caret - 1, data->caret - 1); - SendMessage(hwnd, NSM_SETCARET, data->caret - 1, TRUE); - break; + { + switch (wParam) { + case VK_UP: + SendMessage(hwnd, NSM_SELECTITEMS2, data->caret - 1, data->caret - 1); + SendMessage(hwnd, NSM_SETCARET, data->caret - 1, TRUE); + break; - case VK_DOWN: - SendMessage(hwnd, NSM_SELECTITEMS2, data->caret + 1, data->caret + 1); - SendMessage(hwnd, NSM_SETCARET, data->caret + 1, TRUE); - break; + case VK_DOWN: + SendMessage(hwnd, NSM_SELECTITEMS2, data->caret + 1, data->caret + 1); + SendMessage(hwnd, NSM_SETCARET, data->caret + 1, TRUE); + break; - case VK_PRIOR: - break; + case VK_PRIOR: + break; - case VK_NEXT: - break; + case VK_NEXT: + break; - case VK_HOME: - break; + case VK_HOME: + break; - case VK_END: - break; + case VK_END: + break; - case VK_F2: - BeginEditItem(hwnd, data, data->caret); - break; - } + case VK_F2: + BeginEditItem(hwnd, data, data->caret); break; } + break; + } case WM_SYSCHAR: case WM_CHAR: @@ -436,107 +436,107 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM break; case WM_LBUTTONDOWN: - { - int item = SendMessage(hwnd, NSM_GETITEMFROMPIXEL, LOWORD(lParam), HIWORD(lParam)); - if (item >= 0) { - if (data->caret != item) - EndEditItem(hwnd, data); + { + int item = SendMessage(hwnd, NSM_GETITEMFROMPIXEL, LOWORD(lParam), HIWORD(lParam)); + if (item >= 0) { + if (data->caret != item) + EndEditItem(hwnd, data); - if (wParam & MK_CONTROL) { - SendMessage(hwnd, NSM_TOGGLEITEMS, item, item); + 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 (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 { - if (data->caret == item) { - BeginEditItem(hwnd, data, item); - } - else { - SendMessage(hwnd, NSM_SELECTITEMS2, item, item); - SendMessage(hwnd, NSM_SETCARET, item, TRUE); - } + SendMessage(hwnd, NSM_SELECTITEMS2, item, item); + SendMessage(hwnd, NSM_SETCARET, item, TRUE); } - } + } } - SetFocus(hwnd); - return 0; + } + SetFocus(hwnd); + return 0; case WM_MOUSEWHEEL: - { - DWORD s_scrollTopItem = data->scrollTopItem; - int s_scrollTopPixel = data->scrollTopPixel; + { + DWORD s_scrollTopItem = data->scrollTopItem; + int s_scrollTopPixel = data->scrollTopPixel; - UINT scrollLines; - if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, FALSE)) - scrollLines = 3; - ScrollListBy(hwnd, data, 0, (short)HIWORD(wParam) * 10 * (signed)scrollLines / WHEEL_DELTA); + UINT scrollLines; + if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, FALSE)) + scrollLines = 3; + ScrollListBy(hwnd, data, 0, (short)HIWORD(wParam) * 10 * (signed)scrollLines / WHEEL_DELTA); - if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel)) - InvalidateRect(hwnd, 0, FALSE); + if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel)) + InvalidateRect(hwnd, 0, FALSE); - return TRUE; - } + return TRUE; + } 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: - { - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_TRACKPOS | SIF_RANGE; - GetScrollInfo(hwnd, SB_VERT, &si); - int pos = si.nTrackPos; - - if (pos == si.nMax) { - data->scrollTopItem = data->items.getCount(); - data->scrollTopPixel = -1000; - } - 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; - } - FixScrollPosition(hwnd, data); - } - break; + { + DWORD s_scrollTopItem = data->scrollTopItem; + int s_scrollTopPixel = data->scrollTopPixel; - default: - return 0; + 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; + GetScrollInfo(hwnd, SB_VERT, &si); + int pos = si.nTrackPos; + + if (pos == si.nMax) { + data->scrollTopItem = data->items.getCount(); + data->scrollTopPixel = -1000; } + 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; + } + FixScrollPosition(hwnd, data); + } + break; - if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel)) - InvalidateRect(hwnd, 0, FALSE); - break; + default: + return 0; } + if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel)) + InvalidateRect(hwnd, 0, FALSE); + break; + } + case WM_DESTROY: delete data; SetWindowLongPtr(hwnd, 0, 0); @@ -548,7 +548,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM ///////////////////////////////////////////////////////////////////////// // Utilities -static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int scrollPixels) +static void ScrollListBy(HWND hwnd, NewstoryListData* data, int scrollItems, int scrollPixels) { if (scrollItems) { data->scrollTopItem += scrollItems; @@ -577,11 +577,11 @@ static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int } } } - + FixScrollPosition(hwnd, data); } -static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item) +static void EnsureVisible(HWND hwnd, NewstoryListData* data, int item) { if (data->scrollTopItem >= item) { data->scrollTopItem = item; @@ -614,7 +614,7 @@ static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item) FixScrollPosition(hwnd, data); } -static void FixScrollPosition(HWND hwnd, NewstoryListData *data) +static void FixScrollPosition(HWND hwnd, NewstoryListData* data) { EndEditItem(hwnd, data); @@ -644,7 +644,7 @@ static void FixScrollPosition(HWND hwnd, NewstoryListData *data) RecalcScrollBar(hwnd, data); } -static void RecalcScrollBar(HWND hwnd, NewstoryListData *data) +static void RecalcScrollBar(HWND hwnd, NewstoryListData* data) { SCROLLINFO si = { 0 }; RECT clRect; @@ -658,7 +658,7 @@ static void RecalcScrollBar(HWND hwnd, NewstoryListData *data) SetScrollInfo(hwnd, SB_VERT, &si, TRUE); } -static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index) +static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index) { if (data->hwndEditBox) EndEditItem(hwnd, data); @@ -674,7 +674,7 @@ static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index) int itemHeight = LayoutItem(hwnd, &data->items, idx); while (top < height) { if (idx == index) { - HistoryArray::ItemData *item = data->items.get(index, ELM_DATA); + HistoryArray::ItemData* item = data->items.get(index, ELM_DATA); int tpl; int fontid; @@ -717,8 +717,8 @@ static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index) 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); + wchar_t* text = TplFormatString(tpl, item->hContact, item); + data->hwndEditBox = CreateWindow(L"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); @@ -734,19 +734,19 @@ static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index) } } -static void EndEditItem(HWND, NewstoryListData *data) +static void EndEditItem(HWND, NewstoryListData* data) { DestroyWindow(data->hwndEditBox); data->hwndEditBox = 0; } -static int LayoutItem(HWND hwnd, HistoryArray *items, int index) +static int LayoutItem(HWND hwnd, HistoryArray* items, int index) { HDC hdc = GetDC(hwnd); RECT rc; GetClientRect(hwnd, &rc); int width = rc.right - rc.left; - HistoryArray::ItemData *item = items->get(index, ELM_DATA); + HistoryArray::ItemData* item = items->get(index, ELM_DATA); if (!item) return 0; int tpl; @@ -785,7 +785,7 @@ static int LayoutItem(HWND hwnd, HistoryArray *items, int index) HFONT hfnt = (HFONT)SelectObject(hdc, fonts[fontid].hfnt); if (!item->data) { - TCHAR *buf = TplFormatString(tpl, item->hContact, item); + wchar_t* buf = TplFormatString(tpl, item->hContact, item); item->data = MTextCreateW(htuLog, buf); mir_free(buf); } @@ -800,10 +800,10 @@ static int LayoutItem(HWND hwnd, HistoryArray *items, int index) return sz.cy + 5; } -static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width) +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); + HistoryArray::ItemData* item = items->get(index, ELM_DATA); // LOGFONT lfText; COLORREF clText, clBack, clLine; @@ -861,7 +861,7 @@ static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width } if (!item->data) { - TCHAR *buf = TplFormatString(tpl, item->hContact, item); + wchar_t* buf = TplFormatString(tpl, item->hContact, item); item->data = MTextCreateW(htuLog, buf); mir_free(buf); if (!item->data) diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp index d534fbc4ab..2a34667121 100644 --- a/plugins/NewStory/src/options.cpp +++ b/plugins/NewStory/src/options.cpp @@ -78,7 +78,7 @@ static INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, mir_free(templates[CurrentTemplate].tmpValue); { int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; - templates[CurrentTemplate].tmpValue = (TCHAR *)mir_alloc(length * sizeof(TCHAR)); + templates[CurrentTemplate].tmpValue = (wchar_t*)mir_alloc(length * sizeof(wchar_t)); GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue, length); HistoryArray::ItemData item; @@ -91,15 +91,15 @@ static INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, if (item.hContact && item.hEvent) { item.load(ELM_DATA); - TCHAR *preview = TplFormatStringEx(CurrentTemplate, templates[CurrentTemplate].tmpValue, item.hContact, &item); + wchar_t* 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 :)")); + SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), L"$hit :)"); mir_free(preview); } else { - SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), _T("")); - SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), _T("")); + SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), L""); + SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), L""); } } break; @@ -149,58 +149,58 @@ static INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, 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) - mir_free(templates[lpnmtv->itemOld.lParam].tmpValue); - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; - templates[lpnmtv->itemOld.lParam].tmpValue = (TCHAR *)mir_alloc(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) + mir_free(templates[lpnmtv->itemOld.lParam].tmpValue); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; + templates[lpnmtv->itemOld.lParam].tmpValue = (wchar_t*)mir_alloc(length * sizeof(wchar_t)); + 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) - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].value); - else - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].defvalue); + 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); - } - break; + PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0); + } + break; case TVN_KEYDOWN: case NM_CLICK: diff --git a/plugins/NewStory/src/quicklist.h b/plugins/NewStory/src/quicklist.h index ec4471f30c..3c5b44a78f 100644 --- a/plugins/NewStory/src/quicklist.h +++ b/plugins/NewStory/src/quicklist.h @@ -5,17 +5,17 @@ private: struct Item { T data; - Item *prev, *next; + Item* prev, * next; }; struct CacheItem { CacheItem() : item(0), no(0) {} - Item *item; + Item* item; int no; }; - Item *head, *tail; + Item* head, * tail; int cacheSize, cacheStep, cacheUsed; - CacheItem *cache; + CacheItem* cache; CacheItem last; public: diff --git a/plugins/NewStory/src/stdafx.h b/plugins/NewStory/src/stdafx.h index fe7a59b639..4e965019b4 100644 --- a/plugins/NewStory/src/stdafx.h +++ b/plugins/NewStory/src/stdafx.h @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 2012 Mataes This is free software; you can redistribute it and/or @@ -14,7 +14,7 @@ Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this file; see the file license.txt. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +Boston, MA 02111-1307, USA. */ #pragma once @@ -24,16 +24,13 @@ Boston, MA 02111-1307, USA. #include <process.h> #include <tchar.h> #include <commctrl.h> -//#include <stdio.h> #include <time.h> //Miranda headers #include "newpluginapi.h" #include "win2k.h" #include "m_system.h" -//#include "m_plugins.h" #include "m_clc.h" -//#include "m_clui.h" #include "m_clist.h" #include "m_options.h" #include "m_skin.h" @@ -52,9 +49,6 @@ Boston, MA 02111-1307, USA. #include "m_contacts.h" #include "m_smileyadd.h" -//#include "m_nconvers.h" -//#include "m_MathModule.h" -//#include "m_Snapping_windows.h" #ifndef MTEXT_NOHELPERS #define MTEXT_NOHELPERS #endif // MTEXT_NOHELPERS diff --git a/plugins/NewStory/src/templates.h b/plugins/NewStory/src/templates.h index 71c41c5539..2067d4118f 100644 --- a/plugins/NewStory/src/templates.h +++ b/plugins/NewStory/src/templates.h @@ -10,22 +10,22 @@ enum struct TemplateVars { bool del[256]; - wchar_t *val[256]; + wchar_t* val[256]; }; -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 }; - char *setting; - wchar_t *group; + char* setting; + wchar_t* group; int icon; - wchar_t *title; - wchar_t *defvalue; - wchar_t *value; - wchar_t *tmpValue; + wchar_t* title; + wchar_t* defvalue; + wchar_t* value; + wchar_t* tmpValue; VarFunc vf[VF_COUNT]; }; @@ -60,7 +60,7 @@ extern TemplateInfo templates[TPL_COUNT]; void LoadTemplates(); void SaveTemplates(); -wchar_t *TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData *args); -wchar_t *TplFormatStringEx(int tpl, wchar_t *sztpl, MCONTACT hContact, HistoryArray::ItemData *args); +wchar_t* TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData* args); +wchar_t* TplFormatStringEx(int tpl, wchar_t* sztpl, MCONTACT hContact, HistoryArray::ItemData* args); #endif // __templates_h__
\ No newline at end of file diff --git a/plugins/NewStory/src/utils.cpp b/plugins/NewStory/src/utils.cpp index 9e125ceeee..fc73af9a17 100644 --- a/plugins/NewStory/src/utils.cpp +++ b/plugins/NewStory/src/utils.cpp @@ -7,30 +7,30 @@ DWORD toggleBit(DWORD dw, DWORD bit) return dw | bit; } -bool CheckFilter(TCHAR *buf, TCHAR *filter) +bool CheckFilter(wchar_t* buf, wchar_t* filter) { // MessageBox(0, buf, filter, MB_OK); - int l1 = lstrlen(buf); - int l2 = lstrlen(filter); + int l1 = mir_wstrlen(buf); + int l2 = mir_wstrlen(filter); 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; } -void CopyText(HWND hwnd, TCHAR *text) +void CopyText(HWND hwnd, wchar_t* text) { OpenClipboard(hwnd); EmptyClipboard(); - HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(lstrlen(text) + 1)); - TCHAR *s = (TCHAR *)GlobalLock(hMem); - lstrcpy(s, text); + HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t) * (mir_wstrlen(text) + 1)); + wchar_t* s = (wchar_t*)GlobalLock(hMem); + mir_wstrcpy(s, text); GlobalUnlock(hMem); - #ifdef UNICODE +#ifdef UNICODE SetClipboardData(CF_UNICODETEXT, hMem); - #else +#else SetClipboardData(CF_TEXT, hMem); - #endif +#endif CloseClipboard(); // GlobalFree(hMem); } @@ -205,36 +205,36 @@ void CopyText(HWND hwnd, TCHAR *text) }*/ -char *appendString(char *s1, char *s2) +char* appendString(char* s1, char* s2) { if (s1) { - int l1 = lstrlenA(s1); - int l2 = lstrlenA(s2); - char *buf = (char *)mir_alloc(l1 + l2 + 1); + int l1 = mir_strlen(s1); + int l2 = mir_strlen(s2); + char* buf = (char*)mir_alloc(l1 + l2 + 1); mir_snprintf(buf, l1 + l2 + 1, "%s%s", s1, s2); mir_free(s1); return buf; } else { - char *buf = (char *)mir_alloc(lstrlenA(s2) + 1); - lstrcpyA(buf, s2); + char* buf = (char*)mir_alloc(mir_strlen(s2) + 1); + mir_strcpy(buf, s2); return buf; } } -WCHAR *appendString(WCHAR *s1, WCHAR *s2) +wchar_t* appendString(wchar_t* s1, wchar_t* s2) { if (s1) { - int l1 = lstrlenW(s1); - int l2 = lstrlenW(s2); - WCHAR *buf = (WCHAR *)mir_alloc(sizeof(WCHAR)*(l1 + l2 + 1)); + int l1 = mir_wstrlen(s1); + int l2 = mir_wstrlen(s2); + wchar_t* buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * (l1 + l2 + 1)); mir_snwprintf(buf, l1 + l2 + 1, L"%s%s", s1, s2); mir_free(s1); return buf; } else { - WCHAR *buf = (WCHAR *)mir_alloc(sizeof(WCHAR)*(lstrlenW(s2) + 1)); - lstrcpyW(buf, s2); + wchar_t* buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_wstrlen(s2) + 1)); + mir_wstrcpy(buf, s2); return buf; } } diff --git a/plugins/NewStory/src/utils.h b/plugins/NewStory/src/utils.h index f97af5a829..f5b787e23c 100644 --- a/plugins/NewStory/src/utils.h +++ b/plugins/NewStory/src/utils.h @@ -1,19 +1,8 @@ DWORD toggleBit(DWORD dw, DWORD bit); -bool CheckFilter(TCHAR *buf, TCHAR *filter); +bool CheckFilter(wchar_t* buf, wchar_t* filter); -void CopyText(HWND hwnd, TCHAR *text); -void ExportHistory(HANDLE hContact, char *fnTemplate, char *fn, HWND hwndList); +void CopyText(HWND hwnd, wchar_t* text); +void ExportHistory(HANDLE hContact, char* fnTemplate, char* fn, HWND hwndList); -char *appendString(char *s1, char *s2); -WCHAR *appendString(WCHAR *s1, WCHAR *s2); -/* -#ifdef DEBUG - #define DebugInfo(x) -#else - #define DebugInfo(x) DebugInfo_func x - __forceinline void DebugInfo_func(const TCHAR *title, const TCHAR *fmt, ...) - { - PopUp - } -#endif -*/
\ No newline at end of file +char* appendString(char* s1, char* s2); +wchar_t* appendString(wchar_t* s1, wchar_t* s2); |