From a7c24ca48995cf2bf436156302f96b91bf135409 Mon Sep 17 00:00:00 2001 From: Goraf <22941576+Goraf@users.noreply.github.com> Date: Mon, 13 Nov 2017 15:03:31 +0100 Subject: Code modernize ... * replace 0/NULL with nullptr [using clang-tidy] --- plugins/Alarms/src/alarm_win.cpp | 22 ++++++++-------- plugins/Alarms/src/alarmlist.cpp | 16 ++++++------ plugins/Alarms/src/alarms.cpp | 10 ++++---- plugins/Alarms/src/frame.cpp | 54 ++++++++++++++++++++-------------------- plugins/Alarms/src/options.cpp | 12 ++++----- 5 files changed, 57 insertions(+), 57 deletions(-) (limited to 'plugins/Alarms') diff --git a/plugins/Alarms/src/alarm_win.cpp b/plugins/Alarms/src/alarm_win.cpp index f00893fbc9..f47f1f566d 100644 --- a/plugins/Alarms/src/alarm_win.cpp +++ b/plugins/Alarms/src/alarm_win.cpp @@ -4,13 +4,13 @@ #define ID_TIMER_SOUND 10101 #define SOUND_REPEAT_PERIOD 5000 // milliseconds #define SPEACH_REPEAT_PERIOD 15000 // milliseconds -MWindowList hAlarmWindowList = 0; +MWindowList hAlarmWindowList = nullptr; FontIDW title_font_id, window_font_id; ColourIDW bk_colour_id; -HFONT hTitleFont = 0, hWindowFont = 0; +HFONT hTitleFont = nullptr, hWindowFont = nullptr; COLORREF title_font_colour, window_font_colour; -HBRUSH hBackgroundBrush = 0; +HBRUSH hBackgroundBrush = nullptr; #define WMU_SETFONTS (WM_USER + 61) #define WMU_REFRESH (WM_USER + 62) @@ -43,7 +43,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar wd = new WindowData; wd->moving = false; - wd->alarm = 0; + wd->alarm = nullptr; wd->win_num = win_num++; if (wd->win_num > 0) { @@ -52,7 +52,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar r.top += 20; r.left += 20; - SetWindowPos(hwndDlg, 0, r.left, r.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + SetWindowPos(hwndDlg, nullptr, r.left, r.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); Utils_SaveWindowPosition(hwndDlg, 0, MODULE, "Notify"); } SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)wd); @@ -65,7 +65,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar return FALSE; case WMU_REFRESH: - InvalidateRect(hwndDlg, 0, TRUE); + InvalidateRect(hwndDlg, nullptr, TRUE); return TRUE; case WM_CTLCOLORSTATIC: @@ -99,7 +99,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar if (hBackgroundBrush) { SetClassLongPtr(hwndDlg, GCLP_HBRBACKGROUND, (LONG_PTR)hBackgroundBrush); - InvalidateRect(hwndDlg, 0, TRUE); + InvalidateRect(hwndDlg, nullptr, TRUE); } return TRUE; @@ -154,9 +154,9 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar if (data->action & AAF_SOUND && options.loop_sound) { if (data->sound_num <= 3) - SetTimer(hwndDlg, ID_TIMER_SOUND, SOUND_REPEAT_PERIOD, 0); + SetTimer(hwndDlg, ID_TIMER_SOUND, SOUND_REPEAT_PERIOD, nullptr); else if (data->sound_num == 4) - SetTimer(hwndDlg, ID_TIMER_SOUND, SPEACH_REPEAT_PERIOD, 0); + SetTimer(hwndDlg, ID_TIMER_SOUND, SPEACH_REPEAT_PERIOD, nullptr); } HWND hw = GetDlgItem(hwndDlg, IDC_SNOOZE); @@ -181,7 +181,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar Skin_PlaySound(buff); } else if (data->sound_num == 4) { - if (data->szTitle != NULL && data->szTitle[0] != '\0') { + if (data->szTitle != nullptr && data->szTitle[0] != '\0') { if (ServiceExists("Speak/Say")) { CallService("Speak/Say", 0, (LPARAM)data->szTitle); } @@ -312,7 +312,7 @@ INT_PTR CALLBACK DlgProcAlarm(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar RECT r; GetWindowRect(hwndDlg, &r); - SetWindowPos(hwndDlg, 0, r.left + (newp.x - wd->p.x), r.top + (newp.y - wd->p.y), 0, 0, SWP_NOSIZE | SWP_NOZORDER); + SetWindowPos(hwndDlg, nullptr, r.left + (newp.x - wd->p.x), r.top + (newp.y - wd->p.y), 0, 0, SWP_NOSIZE | SWP_NOZORDER); } wd->p.x = newp.x; wd->p.y = newp.y; diff --git a/plugins/Alarms/src/alarmlist.cpp b/plugins/Alarms/src/alarmlist.cpp index 0ea5f59810..cfa1310cf1 100755 --- a/plugins/Alarms/src/alarmlist.cpp +++ b/plugins/Alarms/src/alarmlist.cpp @@ -20,10 +20,10 @@ bool is_idle = false; void free_alarm_data(ALARM *alarm) { - mir_free(alarm->szTitle); alarm->szTitle = 0; - mir_free(alarm->szDesc); alarm->szDesc = 0; - mir_free(alarm->szCommand); alarm->szCommand = 0; - mir_free(alarm->szCommandParams); alarm->szCommandParams = 0; + mir_free(alarm->szTitle); alarm->szTitle = nullptr; + mir_free(alarm->szDesc); alarm->szDesc = nullptr; + mir_free(alarm->szCommand); alarm->szCommand = nullptr; + mir_free(alarm->szCommandParams); alarm->szCommandParams = nullptr; } void copy_alarm_data(ALARM *dest, ALARM *src) @@ -651,7 +651,7 @@ void DoAlarm(ALARM *alarm) Skin_PlaySound(buff); } else if (alarm->sound_num == 4) { - if (alarm->szTitle != NULL && alarm->szTitle[0] != '\0') { + if (alarm->szTitle != nullptr && alarm->szTitle[0] != '\0') { if (ServiceExists("Speak/Say")) { CallService("Speak/Say", 0, (LPARAM)alarm->szTitle); } @@ -679,7 +679,7 @@ void DoAlarm(ALARM *alarm) } if (alarm->action & AAF_COMMAND) - ShellExecute(0, 0, alarm->szCommand, alarm->szCommandParams, 0, SW_NORMAL); + ShellExecute(nullptr, nullptr, alarm->szCommand, alarm->szCommandParams, nullptr, SW_NORMAL); if (alarm->action & AAF_SYSTRAY) { CLISTEVENT cle = {}; @@ -802,7 +802,7 @@ void InitList() InitAlarmWin(); - timer_id = SetTimer(0, 0, TIMER_PERIOD, TimerProc); + timer_id = SetTimer(nullptr, 0, TIMER_PERIOD, TimerProc); HookEvent(ME_IDLE_CHANGED, IdleChanged); } @@ -814,7 +814,7 @@ void DeinitList() // i don't think this should be necessary, but... mir_cslock lck(alarm_cs); - KillTimer(0, timer_id); + KillTimer(nullptr, timer_id); DestroyHookableEvent(hAlarmTriggeredEvent); diff --git a/plugins/Alarms/src/alarms.cpp b/plugins/Alarms/src/alarms.cpp index dc7de3ca63..0e3139bc50 100644 --- a/plugins/Alarms/src/alarms.cpp +++ b/plugins/Alarms/src/alarms.cpp @@ -78,7 +78,7 @@ void ShowPopup(MCONTACT hContact, const wchar_t *msg) ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = RGB(0, 0, 0); ppd.PluginWindowProc = PopupDlgProc; - ppd.PluginData = 0; + ppd.PluginData = nullptr; ppd.iSeconds = 3; // Now that every field has been filled, we want to see the popup. @@ -103,18 +103,18 @@ HBITMAP LoadBmpFromIcon(int IdRes) rc.right = bih.biWidth; rc.bottom = bih.biHeight; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight); HDC hdcMem = CreateCompatibleDC(hdc); HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem, hBmp); HBRUSH hBkgBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE)); FillRect(hdcMem, &rc, hBkgBrush); - DrawIconEx(hdcMem, 2, 0, hIcon, 16, 16, 0, NULL, DI_NORMAL); + DrawIconEx(hdcMem, 2, 0, hIcon, 16, 16, 0, nullptr, DI_NORMAL); SelectObject(hdcMem, hoBmp); DeleteDC(hdcMem); - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); DeleteObject(hBkgBrush); DeleteObject(hIcon); @@ -124,7 +124,7 @@ HBITMAP LoadBmpFromIcon(int IdRes) static int InitTopToolbarButton(WPARAM, LPARAM) { - TTBButton ttb = { 0 }; + TTBButton ttb = {}; ttb.hIconUp = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TBUP)); ttb.hIconDn = LoadIcon(hInst, MAKEINTRESOURCE(IDI_TBDN)); ttb.pszService = MODULE "/NewAlarm"; diff --git a/plugins/Alarms/src/frame.cpp b/plugins/Alarms/src/frame.cpp index 2d3fc23d8e..fcbc4d75e0 100755 --- a/plugins/Alarms/src/frame.cpp +++ b/plugins/Alarms/src/frame.cpp @@ -1,24 +1,24 @@ #include "stdafx.h" #include "frame.h" -HWND hwnd_plugin = 0; -HWND hwnd_frame = 0; -HWND hwnd_list = 0; +HWND hwnd_plugin = nullptr; +HWND hwnd_frame = nullptr; +HWND hwnd_list = nullptr; int frame_id = -1; FontID font_id; ColourID framebk_colour_id; -HFONT hFont = 0; +HFONT hFont = nullptr; COLORREF fontColour, framebk; -HBRUSH bk_brush = 0; +HBRUSH bk_brush = nullptr; #define CLUIFrameTitleBarClassName "CLUIFrameTitleBar" AlarmList alarm_list; mir_cs list_cs; -HGENMENU hMenuShowReminders = 0; +HGENMENU hMenuShowReminders = nullptr; #define ID_FRAME_UPDATE_TIMER 1011 #define ID_FRAME_SHOWHIDE_TIMER 1012 @@ -62,9 +62,9 @@ LRESULT CALLBACK FrameContainerWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LP RECT r; GetClientRect(hwnd, &r); - SetWindowPos(child, 0, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE); - InvalidateRect(child, 0, TRUE); - InvalidateRect(hwnd, 0, TRUE); + SetWindowPos(child, nullptr, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE); + InvalidateRect(child, nullptr, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); } break; @@ -100,13 +100,13 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_CREATE: hwnd_list = CreateWindow(L"LISTBOX", L"", (WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT | LBS_STANDARD | LBS_NOTIFY | LBS_OWNERDRAWFIXED) & ~LBS_SORT - & ~WS_BORDER, 0, 0, 0, 0, hwnd, NULL, hInst, 0); + & ~WS_BORDER, 0, 0, 0, 0, hwnd, nullptr, hInst, nullptr); return FALSE; case WMU_INITIALIZE: PostMessage(hwnd, WMU_FILL_LIST, 0, 0); - SetTimer(hwnd, ID_FRAME_UPDATE_TIMER, 5000, 0); - SetTimer(hwnd, ID_FRAME_SHOWHIDE_TIMER, 200, 0); + SetTimer(hwnd, ID_FRAME_UPDATE_TIMER, 5000, nullptr); + SetTimer(hwnd, ID_FRAME_SHOWHIDE_TIMER, 200, nullptr); return TRUE; case WM_MEASUREITEM: @@ -135,7 +135,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar SetTextColor(dis->hDC, fontColour); HICON hIcon = (min <= 5 ? hIconList2 : hIconList1); - DrawIconEx(dis->hDC, dis->rcItem.left, (dis->rcItem.top + dis->rcItem.bottom - 16) >> 1, hIcon, 0, 0, 0, NULL, DI_NORMAL); + DrawIconEx(dis->hDC, dis->rcItem.left, (dis->rcItem.top + dis->rcItem.bottom - 16) >> 1, hIcon, 0, 0, 0, nullptr, DI_NORMAL); GetTextExtentPoint32(dis->hDC, alarm.szTitle, (int)mir_wstrlen(alarm.szTitle), &textSize); @@ -213,7 +213,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (frame_id != -1) CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)frame_id, FU_TBREDRAW); - InvalidateRect(hwnd, 0, TRUE); + InvalidateRect(hwnd, nullptr, TRUE); } break; @@ -228,7 +228,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (options.auto_size_vert && IsWindowVisible(hwnd)) { if (FrameIsFloating()) { int height = height_client_to_frame(itemheight * count, GetWindowLongPtr(GetParent(hwnd), GWL_STYLE), GetWindowLongPtr(GetParent(hwnd), GWL_EXSTYLE)); - HWND titleBarHwnd = FindWindowEx(GetParent(hwnd), 0, _A2W(CLUIFrameTitleBarClassName), 0); + HWND titleBarHwnd = FindWindowEx(GetParent(hwnd), nullptr, _A2W(CLUIFrameTitleBarClassName), nullptr); if (titleBarHwnd) { RECT tbr; GetWindowRect(titleBarHwnd, &tbr); @@ -236,7 +236,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar } RECT rp_window; GetWindowRect(GetParent(hwnd), &rp_window); - SetWindowPos(GetParent(hwnd), 0, 0, 0, rp_window.right - rp_window.left, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + SetWindowPos(GetParent(hwnd), nullptr, 0, 0, rp_window.right - rp_window.left, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } else if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME) && frame_id != -1) { CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, frame_id), count * itemheight); @@ -254,8 +254,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar height = min(count * itemheight, winheight - (winheight % itemheight)); if (r2.right - r2.left != width || (r.bottom - r.top > 0 && r2.bottom - r2.top != height)) { - SetWindowPos(hwnd_list, 0, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); - InvalidateRect(hwnd_list, 0, FALSE); + SetWindowPos(hwnd_list, nullptr, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + InvalidateRect(hwnd_list, nullptr, FALSE); } if (options.auto_showhide) { @@ -374,7 +374,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar //ClientToScreen(hwnd_list, &pt); GetCursorPos(&pt); - BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL); + BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, nullptr); DestroyMenu(menu); if (ret) PostMessage(hwnd, WM_COMMAND, ret, 0); @@ -461,7 +461,7 @@ bool ReminderFrameVisible() void SetReminderFrameVisible(bool visible) { - if (frame_id == -1 && hwnd_frame != 0) + if (frame_id == -1 && hwnd_frame != nullptr) ShowWindow(hwnd_frame, visible ? SW_SHOW : SW_HIDE); } @@ -481,7 +481,7 @@ INT_PTR ShowHideMenuFunc(WPARAM, LPARAM) int CreateFrame() { WNDCLASS wndclass = {}; - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW); wndclass.hInstance = hInst; wndclass.lpfnWndProc = FrameWindowProc; wndclass.lpszClassName = L"AlarmsFrame"; @@ -490,7 +490,7 @@ int CreateFrame() if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { hwnd_plugin = CreateWindow(L"AlarmsFrame", TranslateT("Alarms"), WS_CHILD | WS_CLIPCHILDREN, - 0, 0, 10, 10, pcli->hwndContactList, NULL, hInst, NULL); + 0, 0, 10, 10, pcli->hwndContactList, nullptr, hInst, nullptr); CLISTFrame Frame = { sizeof(CLISTFrame) }; Frame.tname = TranslateT("Alarms"); @@ -502,7 +502,7 @@ int CreateFrame() frame_id = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); } else { - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW); wndclass.hInstance = hInst; wndclass.lpfnWndProc = FrameContainerWindowProc; wndclass.lpszClassName = L"AlarmsFrameContainer"; @@ -510,11 +510,11 @@ int CreateFrame() hwnd_frame = CreateWindowEx(WS_EX_TOOLWINDOW, L"AlarmsFrameContainer", TranslateT("Alarms"), (WS_POPUPWINDOW | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN) & ~WS_VISIBLE, - 0, 0, 200, 100, pcli->hwndContactList, NULL, hInst, NULL); + 0, 0, 200, 100, pcli->hwndContactList, nullptr, hInst, nullptr); hwnd_plugin = CreateWindow(L"AlarmsFrame", TranslateT("Alarms"), WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, - 0, 0, 10, 10, hwnd_frame, NULL, hInst, NULL); + 0, 0, 10, 10, hwnd_frame, nullptr, hInst, nullptr); SetWindowLongPtr(hwnd_frame, GWLP_USERDATA, (LONG_PTR)hwnd_plugin); @@ -594,9 +594,9 @@ void RefreshReminderFrame() SendMessage(hwnd_plugin, WMU_FILL_LIST, 0, 0); if (frame_id == -1) - InvalidateRect(hwnd_frame, 0, TRUE); + InvalidateRect(hwnd_frame, nullptr, TRUE); else - InvalidateRect(hwnd_plugin, 0, TRUE); + InvalidateRect(hwnd_plugin, nullptr, TRUE); } void InitFrames() diff --git a/plugins/Alarms/src/options.cpp b/plugins/Alarms/src/options.cpp index dbc5cf3dcc..ec2a9a3467 100755 --- a/plugins/Alarms/src/options.cpp +++ b/plugins/Alarms/src/options.cpp @@ -18,10 +18,10 @@ struct AddEditParam BOOL self_add; }; -HGENMENU hMainMenuItem = 0; +HGENMENU hMainMenuItem = nullptr; // store options dialog window handle statically so it can be refreshed by non-modal add alarm dialog -HWND hwndOptionsDialog = 0; +HWND hwndOptionsDialog = nullptr; static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -628,7 +628,7 @@ static INT_PTR CALLBACK DlgProcAddEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetDlgItemText(hwndDlg, IDC_DESC, buff, _countof(buff)); replaceStrW(add_edit_alarm->szDesc, buff); - if (add_edit_alarm->szTitle == 0 || add_edit_alarm->szTitle[0] == '\0') { + if (add_edit_alarm->szTitle == nullptr || add_edit_alarm->szTitle[0] == '\0') { MessageBox(hwndDlg, TranslateT("Please enter a title for this alarm."), TranslateT("Error"), MB_OK | MB_ICONERROR); return TRUE; } @@ -847,13 +847,13 @@ public: class Node { public: - Node() : next(0) {} + Node() : next(nullptr) {} unsigned short value; Node *next; }; - ShortList() : head(0) {} + ShortList() : head(nullptr) {} virtual ~ShortList() { clear(); } void clear() @@ -1198,7 +1198,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break; case WM_DESTROY: - hwndOptionsDialog = 0; + hwndOptionsDialog = nullptr; added_list.clear(); modified_list.clear(); deleted_list.clear(); -- cgit v1.2.3