From 11be91c6aab5bee9988b5ea9257ec8513871a03b Mon Sep 17 00:00:00 2001 From: GreyMerlin Date: Wed, 24 Oct 2018 15:31:39 -0700 Subject: [PATCH] Various refactorings involving NULL, ASSERT, TRUE and FALSE (3) More of the same... * Mostly in CrystalEdit * And also BCMenu * Change many `return(v);` -> `return v;` * Many changes `= 0` to `= nullptr` * The various `*.c` files must use `NULL` instead of `0` --HG-- branch : stable --- Externals/crystaledit/editlib/ccrystaleditview.cpp | 4 +- Externals/crystaledit/editlib/ccrystaltextview.cpp | 4 +- .../crystaledit/editlib/ccrystaltextview2.cpp | 2 +- Externals/crystaledit/editlib/ceditreplacedlg.cpp | 6 +- Externals/crystaledit/editlib/ceditreplacedlg.h | 8 +- Externals/crystaledit/editlib/cfindtextdlg.cpp | 8 +- Externals/crystaledit/editlib/cfindtextdlg.h | 16 +- Externals/crystaledit/editlib/chcondlg.cpp | 4 +- Externals/crystaledit/editlib/chcondlg.h | 2 +- Externals/crystaledit/editlib/cregexp_poco.cpp | 8 +- Externals/crystaledit/editlib/ctextmarkerdlg.cpp | 6 +- Externals/crystaledit/editlib/ctextmarkerdlg.h | 8 +- Src/Common/BCMenu.cpp | 560 +++++++++++---------- Src/Common/BCMenu.h | 84 ++-- Src/Common/CMoveConstraint.cpp | 18 +- Src/Common/CMoveConstraint.h | 2 +- Src/Common/LanguageSelect.cpp | 14 +- Src/Common/PreferencesDlg.cpp | 30 +- Src/Common/ShellFileOperations.cpp | 2 +- Src/Common/UniFile.cpp | 6 +- Src/Common/lwdisp.c | 32 +- Src/Common/sizecbar.cpp | 26 +- Src/CompareEngines/Wrap_DiffUtils.cpp | 2 +- Src/ConfigLog.cpp | 2 +- Src/ConfigLog.h | 2 +- Src/DiffTextBuffer.cpp | 2 +- Src/DiffTextBuffer.h | 2 +- Src/DiffWrapper.cpp | 28 +- Src/DiffWrapper.h | 5 +- Src/DirActions.h | 4 +- Src/DirDoc.cpp | 6 +- Src/DirView.cpp | 6 +- Src/DirView.h | 2 +- Src/DirViewColItems.cpp | 2 +- Src/EditorFilepathBar.cpp | 8 +- Src/FolderCmp.cpp | 4 +- Src/HexMergeDoc.cpp | 4 +- Src/MainFrm.cpp | 44 +- Src/MainFrm.h | 12 +- Src/MergeCmdLineInfo.cpp | 12 +- Src/MergeCmdLineInfo.h | 2 +- Src/MergeDoc.cpp | 4 +- Src/MovedBlocks.cpp | 8 +- Src/OpenDoc.cpp | 2 +- Src/OpenView.cpp | 4 +- Src/PatchHTML.cpp | 2 +- Src/PluginManager.cpp | 8 +- Src/Plugins.cpp | 4 +- Src/Plugins.h | 2 +- Src/codepage_detect.cpp | 2 +- Src/diffutils/src/analyze.c | 8 +- Src/diffutils/src/context.c | 12 +- Src/diffutils/src/ifdef.c | 12 +- Src/diffutils/src/io.c | 8 +- Src/diffutils/src/util.c | 26 +- Src/files.h | 2 +- Src/markdown.cpp | 12 +- Src/paths.cpp | 30 +- Testing/GoogleTest/Plugins/Plugins_test.cpp | 4 +- 59 files changed, 597 insertions(+), 552 deletions(-) diff --git a/Externals/crystaledit/editlib/ccrystaleditview.cpp b/Externals/crystaledit/editlib/ccrystaleditview.cpp index 921031ed7..4b416179d 100644 --- a/Externals/crystaledit/editlib/ccrystaleditview.cpp +++ b/Externals/crystaledit/editlib/ccrystaleditview.cpp @@ -415,7 +415,7 @@ DeleteCurrentColumnSelection2 (int nStartLine, int nEndLine, int nAction) bool CCrystalEditView:: InsertColumnText (int nLine, int nPos, LPCTSTR pszText, int cchText, int nAction, bool bFlushUndoGroup) { - if (!pszText || cchText == 0) + if (pszText == nullptr || cchText == 0) return false; CTypedPtrArray aLines; @@ -2826,7 +2826,7 @@ OnToolsCharCoding () if (dlg.DoModal () != IDOK) return; LPTSTR pszNew; - if (!iconvert_new (sText, &pszNew, dlg.m_nSource, dlg.m_nDest, dlg.m_bAlpha != false)) + if (!iconvert_new (sText, &pszNew, dlg.m_nSource, dlg.m_nDest, dlg.m_bAlpha)) { ASSERT (pszNew != nullptr); m_pTextBuffer->BeginUndoGroup (); diff --git a/Externals/crystaledit/editlib/ccrystaltextview.cpp b/Externals/crystaledit/editlib/ccrystaltextview.cpp index 86bc99c67..f2f34244d 100644 --- a/Externals/crystaledit/editlib/ccrystaltextview.cpp +++ b/Externals/crystaledit/editlib/ccrystaltextview.cpp @@ -3105,7 +3105,7 @@ OnPrint (CDC * pdc, CPrintInfo * pInfo) CRect rectClip = m_rcPrintArea; rectClip.right = rectClip.left + GetMarginWidth (pdc) + GetScreenChars () * GetCharWidth (); rectClip.bottom = rectClip.top + GetScreenLines () * GetLineHeight (); - if (pdc->IsKindOf (RUNTIME_CLASS (CPreviewDC))) + if (!!pdc->IsKindOf (RUNTIME_CLASS (CPreviewDC))) { CPreviewDC *pPrevDC = (CPreviewDC *)pdc; @@ -4619,7 +4619,7 @@ OnUpdateIndicatorPosition (CCmdUI * pCmdUI) stat.Format (_T ("Ln %d, Col %d"), m_ptCursorPos.y + 1, m_nIdealCharPos + 1); pCmdUI->SetText (stat); //BEGIN SW - if( pCmdUI->m_pOther && pCmdUI->m_pOther->IsKindOf( RUNTIME_CLASS(CStatusBar) ) ) + if( pCmdUI->m_pOther && !!pCmdUI->m_pOther->IsKindOf( RUNTIME_CLASS(CStatusBar) ) ) OnUpdateStatusMessage( (CStatusBar*)pCmdUI->m_pOther ); //END SW } diff --git a/Externals/crystaledit/editlib/ccrystaltextview2.cpp b/Externals/crystaledit/editlib/ccrystaltextview2.cpp index 0a106249e..e0b727ffd 100644 --- a/Externals/crystaledit/editlib/ccrystaltextview2.cpp +++ b/Externals/crystaledit/editlib/ccrystaltextview2.cpp @@ -1110,7 +1110,7 @@ OnRButtonDown (UINT nFlags, CPoint point) bool CCrystalTextView:: IsSelection () { - return !!(m_ptSelStart != m_ptSelEnd); + return (m_ptSelStart != m_ptSelEnd); } void CCrystalTextView:: diff --git a/Externals/crystaledit/editlib/ceditreplacedlg.cpp b/Externals/crystaledit/editlib/ceditreplacedlg.cpp index bcec66eaa..edd722b17 100644 --- a/Externals/crystaledit/editlib/ceditreplacedlg.cpp +++ b/Externals/crystaledit/editlib/ceditreplacedlg.cpp @@ -37,6 +37,8 @@ #include "ceditreplacedlg.h" #include "ccrystaleditview.h" +#include "DDXHelper.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -507,14 +509,14 @@ SetLastSearch (LPCTSTR sText, bool bMatchCase, bool bWholeWord, bool bRegExp, in lastSearch.m_bWholeWord = bWholeWord; lastSearch.m_bRegExp = bRegExp; lastSearch.m_sText = sText; - lastSearch.m_bNoWrap = !!m_bDontWrap; + lastSearch.m_bNoWrap = m_bDontWrap; } void CEditReplaceDlg:: UpdateLastSearch () { - SetLastSearch (m_sText, !!m_bMatchCase, !!m_bWholeWord, !!m_bRegExp, m_nScope); + SetLastSearch (m_sText, m_bMatchCase, m_bWholeWord, m_bRegExp, m_nScope); } void CEditReplaceDlg:: diff --git a/Externals/crystaledit/editlib/ceditreplacedlg.h b/Externals/crystaledit/editlib/ceditreplacedlg.h index 50f71cdc0..ea86ce63a 100644 --- a/Externals/crystaledit/editlib/ceditreplacedlg.h +++ b/Externals/crystaledit/editlib/ceditreplacedlg.h @@ -67,13 +67,13 @@ public : CMemComboBox m_ctlFindText; CMemComboBox m_ctlReplText; CButton m_ctlWholeWord; - BOOL m_bMatchCase; - BOOL m_bWholeWord; - BOOL m_bRegExp; + bool m_bMatchCase; + bool m_bWholeWord; + bool m_bRegExp; CString m_sText; CString m_sNewText; int m_nScope; - BOOL m_bDontWrap; + bool m_bDontWrap; //}}AFX_DATA // Overrides diff --git a/Externals/crystaledit/editlib/cfindtextdlg.cpp b/Externals/crystaledit/editlib/cfindtextdlg.cpp index c288e408e..9c57b335f 100644 --- a/Externals/crystaledit/editlib/cfindtextdlg.cpp +++ b/Externals/crystaledit/editlib/cfindtextdlg.cpp @@ -29,6 +29,8 @@ #include "cfindtextdlg.h" #include "ccrystaltextview.h" +#include "DDXHelper.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -218,15 +220,15 @@ SetLastSearch (LPCTSTR sText, bool bMatchCase, bool bWholeWord, bool bRegExp, in lastSearch.m_bRegExp = bRegExp; lastSearch.m_nDirection = nDirection; lastSearch.m_sText = sText; - lastSearch.m_bNoWrap = !!m_bNoWrap; - lastSearch.m_bNoClose = !!m_bNoClose; + lastSearch.m_bNoWrap = m_bNoWrap; + lastSearch.m_bNoClose = m_bNoClose; } void CFindTextDlg:: UpdateLastSearch () { - SetLastSearch (m_sText, !!m_bMatchCase, !!m_bWholeWord, !!m_bRegExp, m_nDirection); + SetLastSearch (m_sText, m_bMatchCase, m_bWholeWord, m_bRegExp, m_nDirection); } void CFindTextDlg:: diff --git a/Externals/crystaledit/editlib/cfindtextdlg.h b/Externals/crystaledit/editlib/cfindtextdlg.h index bd968ca10..bc89b9fdb 100644 --- a/Externals/crystaledit/editlib/cfindtextdlg.h +++ b/Externals/crystaledit/editlib/cfindtextdlg.h @@ -47,10 +47,10 @@ struct LastSearchInfos { int m_nDirection; // only for search bool m_bNoWrap; - BOOL m_bMatchCase; + bool m_bMatchCase; CString m_sText; - BOOL m_bWholeWord; - BOOL m_bRegExp; + bool m_bWholeWord; + bool m_bRegExp; bool m_bNoClose; }; @@ -79,12 +79,12 @@ public : CMemComboBox m_ctlFindText; CButton m_ctlWholeWord; int m_nDirection; - BOOL m_bMatchCase; + bool m_bMatchCase; CString m_sText; - BOOL m_bWholeWord; - BOOL m_bRegExp; - BOOL m_bNoWrap; - BOOL m_bNoClose; + bool m_bWholeWord; + bool m_bRegExp; + bool m_bNoWrap; + bool m_bNoClose; //}}AFX_DATA // Overrides diff --git a/Externals/crystaledit/editlib/chcondlg.cpp b/Externals/crystaledit/editlib/chcondlg.cpp index 52f61f042..f67b70694 100644 --- a/Externals/crystaledit/editlib/chcondlg.cpp +++ b/Externals/crystaledit/editlib/chcondlg.cpp @@ -19,6 +19,8 @@ #include "ccrystaltextview.h" #include "cs2cs.h" +#include "DDXHelper.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -114,7 +116,7 @@ void CCharConvDlg::OnPreview() { UpdateData (); LPTSTR pszNew; - if (!iconvert_new (m_sOriginal, &pszNew, m_nSource, m_nDest, m_bAlpha != false)) + if (!iconvert_new (m_sOriginal, &pszNew, m_nSource, m_nDest, m_bAlpha)) { m_sPreview = pszNew; UpdateData (false); diff --git a/Externals/crystaledit/editlib/chcondlg.h b/Externals/crystaledit/editlib/chcondlg.h index 79b955911..eae76cd79 100644 --- a/Externals/crystaledit/editlib/chcondlg.h +++ b/Externals/crystaledit/editlib/chcondlg.h @@ -36,7 +36,7 @@ public : CComboBox m_ctlDest; int m_nSource; int m_nDest; - BOOL m_bAlpha; + bool m_bAlpha; CString m_sPreview; //}}AFX_DATA CString m_sOriginal; diff --git a/Externals/crystaledit/editlib/cregexp_poco.cpp b/Externals/crystaledit/editlib/cregexp_poco.cpp index ec0a574ee..c1b8d1624 100644 --- a/Externals/crystaledit/editlib/cregexp_poco.cpp +++ b/Externals/crystaledit/editlib/cregexp_poco.cpp @@ -34,10 +34,10 @@ struct _RxNode { }; RxNode *RxCompile(LPCTSTR Regexp, unsigned int RxOpt) { - RxNode *n = 0; - if (Regexp == 0) return 0; + RxNode *n = nullptr; + if (Regexp == nullptr) return nullptr; n = new RxNode(); - if (n == 0) return 0; + if (n == nullptr) return nullptr; const char * errormsg = NULL; int erroroffset = 0; @@ -60,7 +60,7 @@ RxNode *RxCompile(LPCTSTR Regexp, unsigned int RxOpt) { } catch (...) { - return 0; + return nullptr; } return n; diff --git a/Externals/crystaledit/editlib/ctextmarkerdlg.cpp b/Externals/crystaledit/editlib/ctextmarkerdlg.cpp index 30166d8b7..7bf3ac925 100644 --- a/Externals/crystaledit/editlib/ctextmarkerdlg.cpp +++ b/Externals/crystaledit/editlib/ctextmarkerdlg.cpp @@ -11,6 +11,8 @@ #include "ccrystaltextview.h" #include +#include "DDXHelper.h" + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -56,7 +58,7 @@ DoDataExchange (CDataExchange * pDX) if (pDX->m_bSaveAndValidate) UpdateDataListView(true); else - m_ctlWholeWord.EnableWindow(!m_bRegExp); + m_ctlWholeWord.EnableWindow(m_bRegExp ? FALSE : TRUE); //}}AFX_DATA_MAP } @@ -209,7 +211,7 @@ void CTextMarkerDlg::OnBnClickedApplyNow() const TCHAR *pKey = reinterpret_cast(m_listMarkers.GetItemData(i)); m_tempMarkers.GetMarkers()[pKey].bVisible = !!m_listMarkers.GetCheck(i); } - m_tempMarkers.SetEnabled(!!m_bMarkersEnabled); + m_tempMarkers.SetEnabled(m_bMarkersEnabled); m_markers = m_tempMarkers; m_markers.UpdateViews(); } diff --git a/Externals/crystaledit/editlib/ctextmarkerdlg.h b/Externals/crystaledit/editlib/ctextmarkerdlg.h index c24bca4a9..fe91f310f 100644 --- a/Externals/crystaledit/editlib/ctextmarkerdlg.h +++ b/Externals/crystaledit/editlib/ctextmarkerdlg.h @@ -35,10 +35,10 @@ public : CString m_sFindWhat; int m_nBgColorIndex; int m_nCurItemIndex; - BOOL m_bMatchCase; - BOOL m_bWholeWord; - BOOL m_bRegExp; - BOOL m_bMarkersEnabled; + bool m_bMatchCase; + bool m_bWholeWord; + bool m_bRegExp; + bool m_bMarkersEnabled; //}}AFX_DATA // Overrides diff --git a/Src/Common/BCMenu.cpp b/Src/Common/BCMenu.cpp index b488d25e8..19786a58f 100644 --- a/Src/Common/BCMenu.cpp +++ b/Src/Common/BCMenu.cpp @@ -53,7 +53,7 @@ int BCMenu::m_textBorder = 0; int BCMenu::m_checkBgWidth = 0; int BCMenu::m_gutterWidth = 0; int BCMenu::m_arrowWidth = 0; -HTHEME BCMenu::m_hTheme = NULL; +HTHEME BCMenu::m_hTheme = nullptr; // The Representation of a 32 bit color table entry @@ -150,20 +150,20 @@ BCMenu::BCMenu() { // set the color used for the transparent background in all bitmaps m_bitmapBackground=RGB(192,192,192); //gray - m_bitmapBackgroundFlag=FALSE; - m_loadmenu=FALSE; - if (!m_hTheme && IsThemeActive()) + m_bitmapBackgroundFlag=false; + m_loadmenu=false; + if (m_hTheme==nullptr && IsThemeActive()) { - m_hTheme = OpenThemeData(NULL, _T("MENU")); - if (m_hTheme) + m_hTheme = OpenThemeData(nullptr, _T("MENU")); + if (m_hTheme != nullptr) { MARGINS marginCheckBg, marginArrow; - GetThemePartSize(m_hTheme, NULL, MENU_POPUPCHECK, 0, NULL, TS_TRUE, &m_sizeCheck); - GetThemeMargins(m_hTheme, NULL, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, NULL, &m_marginCheck); - GetThemePartSize(m_hTheme, NULL, MENU_POPUPSEPARATOR, 0, NULL, TS_TRUE, &m_sizeSeparator); - GetThemeMargins(m_hTheme, NULL, MENU_POPUPSEPARATOR, 0, TMT_SIZINGMARGINS, NULL, &m_marginSeparator); - GetThemeMargins(m_hTheme, NULL, MENU_POPUPCHECKBACKGROUND, 0, TMT_CONTENTMARGINS, NULL, &marginCheckBg); - GetThemeMargins(m_hTheme, NULL, MENU_POPUPSUBMENU, 0, TMT_CONTENTMARGINS, NULL, &marginArrow); + GetThemePartSize(m_hTheme, nullptr, MENU_POPUPCHECK, 0, nullptr, TS_TRUE, &m_sizeCheck); + GetThemeMargins(m_hTheme, nullptr, MENU_POPUPCHECK, 0, TMT_CONTENTMARGINS, nullptr, &m_marginCheck); + GetThemePartSize(m_hTheme, nullptr, MENU_POPUPSEPARATOR, 0, nullptr, TS_TRUE, &m_sizeSeparator); + GetThemeMargins(m_hTheme, nullptr, MENU_POPUPSEPARATOR, 0, TMT_SIZINGMARGINS, nullptr, &m_marginSeparator); + GetThemeMargins(m_hTheme, nullptr, MENU_POPUPCHECKBACKGROUND, 0, TMT_CONTENTMARGINS, nullptr, &marginCheckBg); + GetThemeMargins(m_hTheme, nullptr, MENU_POPUPSUBMENU, 0, TMT_CONTENTMARGINS, nullptr, &marginArrow); GetThemeInt(m_hTheme, MENU_POPUPBACKGROUND, 0, TMT_BORDERSIZE, &m_textBorder); m_checkBgWidth = m_marginCheck.cxLeftWidth + m_sizeCheck.cx + m_marginCheck.cxRightWidth; m_gutterWidth = marginCheckBg.cxLeftWidth + m_checkBgWidth + marginCheckBg.cxRightWidth; @@ -180,16 +180,16 @@ BCMenu::~BCMenu() BCMenuData::~BCMenuData() { - if(bitmap) + if(bitmap!=nullptr) delete(bitmap); - delete[] m_szMenuText; //Need not check for NULL because ANSI X3J16 allows "delete NULL" + delete[] m_szMenuText; //Need not check for nullptr because ANSI X3J16 allows "delete nullptr" } void BCMenuData::SetWideString(const wchar_t *szWideString) { - delete[] m_szMenuText;//Need not check for NULL because ANSI X3J16 allows "delete NULL" + delete[] m_szMenuText;//Need not check for nullptr because ANSI X3J16 allows "delete nullptr" if (szWideString) { @@ -199,7 +199,7 @@ void BCMenuData::SetWideString(const wchar_t *szWideString) wcscpy_s(m_szMenuText, MenuSiz, szWideString); } else - m_szMenuText=NULL;//set to NULL so we need not bother about dangling non-NULL Ptrs + m_szMenuText=nullptr;//set to nullptr so we need not bother about dangling non-nullptr Ptrs } bool BCMenu::IsMenu(CMenu *submenu) @@ -214,9 +214,9 @@ bool BCMenu::IsMenu(HMENU submenu) for(m=0;m<=numSubMenus;++m){ if(submenu==m_AllSubMenus[m] || static_cast(reinterpret_cast(submenu)) == static_cast(reinterpret_cast(m_AllSubMenus[m]))) - return(true); + return true; } - return(false); + return false; } BOOL BCMenu::DestroyMenu() @@ -234,8 +234,8 @@ BOOL BCMenu::DestroyMenu() if(m_AllSubMenus[n]==m_SubMenus[m])m_AllSubMenus.RemoveAt(n); } CMenu *ptr=FromHandle(m_SubMenus[m]); - if(ptr){ - BOOL flag=ptr->IsKindOf(RUNTIME_CLASS( BCMenu )); + if(ptr != nullptr){ + bool flag = !!ptr->IsKindOf(RUNTIME_CLASS( BCMenu )); if(flag)delete(static_cast(ptr)); } } @@ -245,7 +245,7 @@ BOOL BCMenu::DestroyMenu() for(m = 0; m <= numItems; m++)delete(m_MenuList[m]); m_MenuList.RemoveAll(); // Call base-class implementation last: - return(CMenu::DestroyMenu()); + return CMenu::DestroyMenu(); }; /* @@ -263,9 +263,9 @@ void BCMenu::DrawItem (LPDRAWITEMSTRUCT lpDIS) { ASSERT(lpDIS != nullptr); CDC* pDC = CDC::FromHandle(lpDIS->hDC); - if(pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE)DrawItem_Win9xNT2000(lpDIS); + if((pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE) != 0)DrawItem_Win9xNT2000(lpDIS); else{ - if (!m_hTheme || !IsThemeActive()) + if (m_hTheme == nullptr || !IsThemeActive()) DrawItem_Win9xNT2000(lpDIS); else DrawItem_Theme(lpDIS); @@ -281,7 +281,7 @@ void BCMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS) COLORREF clrBack=GetSysColor(COLOR_MENU); CBrush brBackground(clrBack); - if(state0 & MF_SEPARATOR){ + if((state0 & MF_SEPARATOR) != 0){ rect.CopyRect(&lpDIS->rcItem); pDC->FillRect (rect,&brBackground); rect.top += (rect.Height()>>1); @@ -297,7 +297,7 @@ void BCMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS) int x0,y0,dy; int nIconNormal=-1; INT_PTR xoffset=-1; - CImageList *bitmap=NULL; + CImageList *bitmap=nullptr; // set some colors CPen penBack(PS_SOLID,0,clrBack); @@ -327,25 +327,28 @@ void BCMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS) bitmap = &m_AllImages; } - if(state&ODS_CHECKED && nIconNormal<0){ + if((state&ODS_CHECKED)!=0 && nIconNormal<0){ } else if(nIconNormal != -1){ standardflag=true; - if(state&ODS_SELECTED && !(state&ODS_GRAYED))selectedflag=true; - else if(state&ODS_GRAYED) disableflag=true; + if((state&ODS_SELECTED)!=0 && (state&ODS_GRAYED)==0) + selectedflag=true; + else + if((state&ODS_GRAYED)!=0) + disableflag=true; } } else{ strText.Empty(); } - if(state&ODS_SELECTED){ // draw the down edges + if((state&ODS_SELECTED)!=0){ // draw the down edges CPen *pOldPen = pDC->SelectObject (&penBack); // You need only Text highlight and thats what you get - if(checkflag||standardflag||selectedflag||disableflag||state&ODS_CHECKED) + if(checkflag||standardflag||selectedflag||disableflag||(state&ODS_CHECKED)!=0) rect2.SetRect(rect.left+m_iconX+4+BCMENU_GAP,rect.top,rect.right,rect.bottom); pDC->FillRect (rect2,&brSelect); @@ -418,17 +421,16 @@ void BCMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS) if(bitmap)bitmap->Draw(pDC,(int)xoffset,ptImage,ILD_TRANSPARENT); } } - if(nIconNormal<0 && state&ODS_CHECKED && !checkflag){ + if(nIconNormal<0 && (state&ODS_CHECKED)!=0 && !checkflag){ rect2.SetRect(rect.left+1,rect.top+2+dy,rect.left+m_iconX+1, rect.top+m_iconY+2+dy); CMenuItemInfo info; info.fMask = MIIM_CHECKMARKS; ::GetMenuItemInfo((HMENU)lpDIS->hwndItem,lpDIS->itemID, MF_BYCOMMAND, &info); - if(state&ODS_CHECKED || info.hbmpUnchecked) { - Draw3DCheckmark(pDC, rect2, state&ODS_SELECTED, - (state&ODS_CHECKED) ? info.hbmpChecked : - info.hbmpUnchecked); + if((state&ODS_CHECKED)!=0 || info.hbmpUnchecked!=nullptr) { + Draw3DCheckmark(pDC, rect2, (state&ODS_SELECTED)!=0, + (state&ODS_CHECKED)!=0 ? info.hbmpChecked : info.hbmpUnchecked); } } @@ -460,7 +462,7 @@ void BCMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS) UINT nFormat = DT_LEFT|DT_SINGLELINE|DT_VCENTER; UINT nFormatr = DT_RIGHT|DT_SINGLELINE|DT_VCENTER; - if(!(lpDIS->itemState & ODS_GRAYED)){ + if((lpDIS->itemState & ODS_GRAYED)==0){ pDC->SetTextColor(crText); pDC->DrawText (leftStr,rectt,nFormat); if(tablocr!=-1) pDC->DrawText (rightStr,rectt,nFormatr); @@ -468,7 +470,7 @@ void BCMenu::DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS) else{ // Draw the disabled text - if(!(state & ODS_SELECTED)){ + if((state & ODS_SELECTED)==0){ RECT offset = *rectt; offset.left+=1; offset.right+=1; @@ -505,7 +507,7 @@ inline COLORREF BCMenu::LightenColor(COLORREF col,double factor) lightblue = (BYTE)((factor*(255-blue)) + blue); col = RGB(lightred,lightgreen,lightblue); } - return(col); + return col; } void BCMenu::DrawItem_Theme(LPDRAWITEMSTRUCT lpDIS) @@ -518,25 +520,25 @@ void BCMenu::DrawItem_Theme(LPDRAWITEMSTRUCT lpDIS) CRect rectGutter(rect.left, rect.top, rect.left + m_gutterWidth, rect.bottom); const int stateId = - (state & ODS_GRAYED) ? - ((state & ODS_SELECTED) ? MPI_DISABLEDHOT : MPI_DISABLED) + (state & ODS_GRAYED)!=0 ? + ((state & ODS_SELECTED)!=0 ? MPI_DISABLEDHOT : MPI_DISABLED) : - ((state & ODS_SELECTED) ? MPI_HOT : MPI_NORMAL); + ((state & ODS_SELECTED)!=0 ? MPI_HOT : MPI_NORMAL); - DrawThemeBackground(m_hTheme, hDC, MENU_POPUPBACKGROUND, 0, &rect, NULL); - DrawThemeBackground(m_hTheme, hDC, MENU_POPUPGUTTER, 0, &rectGutter, NULL); - DrawThemeBackground(m_hTheme, hDC, MENU_POPUPITEM, stateId, &rect, NULL); + DrawThemeBackground(m_hTheme, hDC, MENU_POPUPBACKGROUND, 0, &rect, nullptr); + DrawThemeBackground(m_hTheme, hDC, MENU_POPUPGUTTER, 0, &rectGutter, nullptr); + DrawThemeBackground(m_hTheme, hDC, MENU_POPUPITEM, stateId, &rect, nullptr); BCMenuData *mdata = reinterpret_cast(lpDIS->itemData); - if(!mdata) + if(mdata == nullptr) return; - if ((mdata->nFlags & MF_SEPARATOR)){ + if ((mdata->nFlags & MF_SEPARATOR)!=0){ CRect rectSeparator(rectGutter.right + m_marginSeparator.cxLeftWidth, rect.top + m_marginSeparator.cyTopHeight, rect.right - m_marginSeparator.cxRightWidth, rect.top + m_marginSeparator.cyTopHeight + m_sizeSeparator.cy); - DrawThemeBackground(m_hTheme, hDC, MENU_POPUPSEPARATOR, 0, &rectSeparator, NULL); + DrawThemeBackground(m_hTheme, hDC, MENU_POPUPSEPARATOR, 0, &rectSeparator, nullptr); return; } @@ -558,7 +560,7 @@ void BCMenu::DrawItem_Theme(LPDRAWITEMSTRUCT lpDIS) dx = dx<0 ? 0 : dx; if(nIconNormal != -1){ - if(state & ODS_GRAYED){ + if((state & ODS_GRAYED)!=0){ CBitmap bitmapstandard; GetBitmapFromImageList(pDC,bitmap,(int)xoffset,bitmapstandard); COLORREF transparentcol = pDC->GetPixel(rect.left+dx,rect.top+dy); @@ -570,32 +572,32 @@ void BCMenu::DrawItem_Theme(LPDRAWITEMSTRUCT lpDIS) bitmapstandard,0,0,transparentcol); } else{ - if(bitmap){ + if(bitmap!=nullptr){ CPoint ptImage(rect.left+dx,rect.top+dy); bitmap->Draw(pDC,(int)xoffset,ptImage,ILD_TRANSPARENT); } } } - if(nIconNormal<0 && state&ODS_CHECKED){ + if(nIconNormal<0 && (state&ODS_CHECKED)!=0){ CMenuItemInfo info; info.fMask = MIIM_CHECKMARKS; ::GetMenuItemInfo((HMENU)lpDIS->hwndItem,lpDIS->itemID, MF_BYCOMMAND, &info); - if(state&ODS_CHECKED || info.hbmpUnchecked) { + if((state&ODS_CHECKED)!=0 || (info.hbmpUnchecked != nullptr)) { int stateIdCheck = 0; - if (!info.hbmpChecked) - stateIdCheck = (state & ODS_GRAYED) ? MC_CHECKMARKDISABLED : MC_CHECKMARKNORMAL; + if (info.hbmpChecked == nullptr) + stateIdCheck = (state & ODS_GRAYED)!=0 ? MC_CHECKMARKDISABLED : MC_CHECKMARKNORMAL; else - stateIdCheck = (state & ODS_GRAYED) ? MC_BULLETDISABLED : MC_BULLETNORMAL; - int stateIdCheckBk = (state & ODS_GRAYED) ? MCB_DISABLED : MCB_NORMAL; + stateIdCheck = (state & ODS_GRAYED)!=0 ? MC_BULLETDISABLED : MC_BULLETNORMAL; + int stateIdCheckBk = (state & ODS_GRAYED)!=0 ? MCB_DISABLED : MCB_NORMAL; CRect rectCheck( rect.left + m_marginCheck.cxLeftWidth, rect.top + m_marginCheck.cyTopHeight, rect.left + m_marginCheck.cxLeftWidth + m_sizeCheck.cx, rect.top + m_marginCheck.cyTopHeight + m_sizeCheck.cy); CRect rectCheckBg(rect.left,rect.top,rect.left+m_checkBgWidth,rect.bottom); - DrawThemeBackground(m_hTheme, hDC, MENU_POPUPCHECKBACKGROUND, stateIdCheckBk, &rectCheckBg, NULL); - DrawThemeBackground(m_hTheme, hDC, MENU_POPUPCHECK, stateIdCheck, &rectCheck, NULL); + DrawThemeBackground(m_hTheme, hDC, MENU_POPUPCHECKBACKGROUND, stateIdCheckBk, &rectCheckBg, nullptr); + DrawThemeBackground(m_hTheme, hDC, MENU_POPUPCHECK, stateIdCheck, &rectCheck, nullptr); } } @@ -623,14 +625,14 @@ void BCMenu::DrawItem_Theme(LPDRAWITEMSTRUCT lpDIS) UINT nFormat = DT_LEFT|DT_SINGLELINE|DT_VCENTER; UINT nFormatr = DT_RIGHT|DT_SINGLELINE|DT_VCENTER; pDC->SetTextColor( - (!(lpDIS->itemState & ODS_GRAYED)) ? GetSysColor(COLOR_MENUTEXT) : GetSysColor(COLOR_GRAYTEXT)); + ((lpDIS->itemState & ODS_GRAYED)==0) ? GetSysColor(COLOR_MENUTEXT) : GetSysColor(COLOR_GRAYTEXT)); pDC->DrawText (leftStr,rectt,nFormat); if(tablocr!=-1) pDC->DrawText (rightStr,rectt,nFormatr); pDC->SetBkMode( iOldMode ); } } -BOOL BCMenu::GetBitmapFromImageList(CDC* pDC,CImageList *imglist,int nIndex,CBitmap &bmp) +bool BCMenu::GetBitmapFromImageList(CDC* pDC,CImageList *imglist,int nIndex,CBitmap &bmp) { CDC dc; dc.CreateCompatibleDC(pDC); @@ -659,7 +661,7 @@ BOOL BCMenu::GetBitmapFromImageList(CDC* pDC,CImageList *imglist,int nIndex,CBit ImageList_DrawIndirect(&drawing); dc.SelectObject( pOldBmp ); - return(TRUE); + return true; } /* @@ -677,9 +679,9 @@ void BCMenu::MeasureItem(LPMEASUREITEMSTRUCT) void BCMenu::MeasureItem( LPMEASUREITEMSTRUCT lpMIS ) { UINT state = reinterpret_cast(lpMIS->itemData)->nFlags; - if(state & MF_SEPARATOR){ + if((state & MF_SEPARATOR)!=0){ lpMIS->itemWidth = 0; - if (m_hTheme) + if (m_hTheme != nullptr) lpMIS->itemHeight = m_marginSeparator.cyTopHeight + m_sizeSeparator.cy + m_marginSeparator.cyBottomHeight; else lpMIS->itemHeight = 3; @@ -687,13 +689,13 @@ void BCMenu::MeasureItem( LPMEASUREITEMSTRUCT lpMIS ) else{ CFont fontMenu; NONCLIENTMETRICS nm = { sizeof NONCLIENTMETRICS }; - VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, + VERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, nm.cbSize,&nm,0)); fontMenu.CreateFontIndirect (&nm.lfMenuFont); // Obtain the width of the text: CClientDC dc(AfxGetMainWnd() ? AfxGetMainWnd() : CWnd::GetDesktopWindow()); // Get device context - CFont* pFont=NULL; // Select menu font in... + CFont* pFont=nullptr; // Select menu font in... pFont = dc.SelectObject (&fontMenu);// Select menu font in... @@ -724,7 +726,7 @@ void BCMenu::MeasureItem( LPMEASUREITEMSTRUCT lpMIS ) // Set width and height: const int BCMENU_PAD=4; - if (!m_hTheme) + if (m_hTheme == nullptr) lpMIS->itemWidth = m_iconX+BCMENU_PAD+8+t.cx; else lpMIS->itemWidth = m_gutterWidth+m_textBorder+t.cx+m_arrowWidth; @@ -739,17 +741,21 @@ void BCMenu::SetIconSize (int width, int height) m_iconY = height; } -BOOL BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, +bool BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, int nIconNormal) { // Add the MF_OWNERDRAW flag if not specified: - if(!nID){ - if(nFlags&MF_BYPOSITION)nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; - else nFlags=MF_SEPARATOR|MF_OWNERDRAW; - } - else if(!(nFlags & MF_OWNERDRAW))nFlags |= MF_OWNERDRAW; + if(nID == 0){ + if((nFlags&MF_BYPOSITION)!=0) + nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; + else + nFlags=MF_SEPARATOR|MF_OWNERDRAW; + } + else + if((nFlags & MF_OWNERDRAW)==0) + nFlags |= MF_OWNERDRAW; - if(nFlags & MF_POPUP){ + if((nFlags & MF_POPUP)!=0){ m_AllSubMenus.Add((HMENU)nID); m_SubMenus.Add((HMENU)nID); } @@ -762,9 +768,9 @@ BOOL BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, mdata->xoffset = -1; if(nIconNormal>=0){ - if(mdata->bitmap){ + if(mdata->bitmap != nullptr){ mdata->bitmap->DeleteImageList(); - mdata->bitmap=NULL; + mdata->bitmap=nullptr; } mdata->global_offset = AddToGlobalImageList(nIconNormal,static_cast(nID)); } @@ -772,22 +778,26 @@ BOOL BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, mdata->nFlags = nFlags; mdata->nID = nID; - BOOL returnflag=CMenu::AppendMenu(nFlags, nID, (LPCTSTR)mdata); + bool returnflag=!!CMenu::AppendMenu(nFlags, nID, (LPCTSTR)mdata); if(m_loadmenu)RemoveTopLevelOwnerDraw(); - return(returnflag); + return returnflag; } -BOOL BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, +bool BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, CImageList *il,int xoffset) { // Add the MF_OWNERDRAW flag if not specified: - if(!nID){ - if(nFlags&MF_BYPOSITION)nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; - else nFlags=MF_SEPARATOR|MF_OWNERDRAW; - } - else if(!(nFlags & MF_OWNERDRAW))nFlags |= MF_OWNERDRAW; + if(nID==0){ + if((nFlags&MF_BYPOSITION)!=0) + nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; + else + nFlags=MF_SEPARATOR|MF_OWNERDRAW; + } + else + if((nFlags & MF_OWNERDRAW)==0) + nFlags |= MF_OWNERDRAW; - if(nFlags & MF_POPUP){ + if((nFlags & MF_POPUP)!=0){ m_AllSubMenus.Add((HMENU)nID); m_SubMenus.Add((HMENU)nID); } @@ -796,11 +806,13 @@ BOOL BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, m_MenuList.Add(mdata); mdata->SetWideString(lpstrText); //SK: modified for dynamic allocation - if(il){ + if(il != nullptr){ mdata->menuIconNormal = 0; mdata->xoffset=0; - if(mdata->bitmap)mdata->bitmap->DeleteImageList(); - else mdata->bitmap=new(CImageList); + if(mdata->bitmap != nullptr) + mdata->bitmap->DeleteImageList(); + else + mdata->bitmap=new(CImageList); ImageListDuplicate(il,xoffset,mdata->bitmap); } else{ @@ -809,27 +821,30 @@ BOOL BCMenu::AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, } mdata->nFlags = nFlags; mdata->nID = nID; - return(CMenu::AppendMenu(nFlags, nID, (LPCTSTR)mdata)); + return !!CMenu::AppendMenu(nFlags, nID, (LPCTSTR)mdata); } -BOOL BCMenu::InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, +bool BCMenu::InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, int nIconNormal) { - if(!(nFlags & MF_BYPOSITION)){ + if((nFlags & MF_BYPOSITION) == 0){ UINT iPosition =0; BCMenu* pMenu = FindMenuOption(nPosition,iPosition); - if(pMenu){ - return(pMenu->InsertODMenuW(iPosition,lpstrText,nFlags|MF_BYPOSITION,nID,nIconNormal)); + if(pMenu != nullptr){ + return pMenu->InsertODMenuW(iPosition,lpstrText,nFlags|MF_BYPOSITION,nID,nIconNormal); } - else return(FALSE); + else return false; } - if(!nID)nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; - else if(!(nFlags & MF_OWNERDRAW))nFlags |= MF_OWNERDRAW; + if(nID==0) + nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; + else + if((nFlags & MF_OWNERDRAW)==0) + nFlags |= MF_OWNERDRAW; int menustart=0; - if(nFlags & MF_POPUP){ + if((nFlags & MF_POPUP)!=0){ if(m_loadmenu){ menustart=GetMenuStart(); if(nPosition<(UINT)menustart)menustart=0; @@ -848,36 +863,39 @@ BOOL BCMenu::InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PT mdata->menuIconNormal = nIconNormal; mdata->xoffset=-1; if(nIconNormal>=0){ - if(mdata->bitmap){ + if(mdata->bitmap != nullptr){ mdata->bitmap->DeleteImageList(); - mdata->bitmap=NULL; + mdata->bitmap=nullptr; } mdata->global_offset = AddToGlobalImageList(nIconNormal, static_cast(nID)); } else mdata->global_offset = GlobalImageListOffset(static_cast(nID)); mdata->nFlags = nFlags; mdata->nID = nID; - BOOL returnflag=CMenu::InsertMenu(nPosition,nFlags,nID,(LPCTSTR)mdata); + bool returnflag=!!CMenu::InsertMenu(nPosition,nFlags,nID,(LPCTSTR)mdata); if(m_loadmenu)RemoveTopLevelOwnerDraw(); - return(returnflag); + return returnflag; } -BOOL BCMenu::InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, +bool BCMenu::InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PTR nID, CImageList *il,int xoffset) { - if(!(nFlags & MF_BYPOSITION)){ + if((nFlags & MF_BYPOSITION)==0){ UINT iPosition =0; BCMenu* pMenu = FindMenuOption(nPosition,iPosition); - if(pMenu){ - return(pMenu->InsertODMenuW(iPosition,lpstrText,nFlags|MF_BYPOSITION,nID,il,xoffset)); + if(pMenu != nullptr){ + return pMenu->InsertODMenuW(iPosition,lpstrText,nFlags|MF_BYPOSITION,nID,il,xoffset); } - else return(FALSE); + else return false; } - if(!nID)nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; - else if(!(nFlags & MF_OWNERDRAW))nFlags |= MF_OWNERDRAW; + if(nID==0) + nFlags=MF_SEPARATOR|MF_OWNERDRAW|MF_BYPOSITION; + else + if((nFlags & MF_OWNERDRAW)==0) + nFlags |= MF_OWNERDRAW; - if(nFlags & MF_POPUP){ + if((nFlags & MF_POPUP) != 0){ m_AllSubMenus.Add((HMENU)nID); m_SubMenus.Add((HMENU)nID); } @@ -892,19 +910,19 @@ BOOL BCMenu::InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PT mdata->menuIconNormal = -1; mdata->xoffset = -1; - if(il){ - if(mdata->bitmap){ + if(il != nullptr){ + if(mdata->bitmap != nullptr){ mdata->bitmap->DeleteImageList(); - mdata->bitmap=NULL; + mdata->bitmap=nullptr; } mdata->global_offset = AddToGlobalImageList(il,xoffset, static_cast(nID)); } mdata->nFlags = nFlags; mdata->nID = nID; - return(CMenu::InsertMenu(nPosition,nFlags,nID,(LPCTSTR)mdata)); + return !!CMenu::InsertMenu(nPosition,nFlags,nID,(LPCTSTR)mdata); } -BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,int nIconNormal) +bool BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,int nIconNormal) { UINT nLoc; BCMenuData *mdata; @@ -914,7 +932,7 @@ BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,int nIconNormal) // Find the old BCMenuData structure: BCMenu *psubmenu = FindMenuOption(static_cast(nID),nLoc); do{ - if(psubmenu && nLoc!=-1)mdata = psubmenu->m_MenuList[nLoc]; + if(psubmenu!=nullptr && nLoc!=-1)mdata = psubmenu->m_MenuList[nLoc]; else{ // Create a new BCMenuData structure: mdata = new BCMenuData; @@ -922,14 +940,14 @@ BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,int nIconNormal) } ASSERT(mdata != nullptr); - if(lpstrText) + if(lpstrText != nullptr) mdata->SetWideString(lpstrText); //SK: modified for dynamic allocation mdata->menuIconNormal = -1; mdata->xoffset = -1; if(nIconNormal>=0){ - if(mdata->bitmap){ + if(mdata->bitmap != nullptr){ mdata->bitmap->DeleteImageList(); - mdata->bitmap=NULL; + mdata->bitmap=nullptr; } mdata->global_offset = AddToGlobalImageList(nIconNormal, static_cast(nID)); } @@ -939,13 +957,15 @@ BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,int nIconNormal) mdata->nID = nID; bcsubs.Add(psubmenu); bclocs.Add(nLoc); - if(psubmenu && nLoc!=-1)psubmenu = FindAnotherMenuOption(static_cast(nID),nLoc,bcsubs,bclocs); - else psubmenu=NULL; - }while(psubmenu); - return (CMenu::ModifyMenu(static_cast(nID),mdata->nFlags, static_cast(nID),(LPCTSTR)mdata)); + if(psubmenu!=nullptr && nLoc!=-1) + psubmenu = FindAnotherMenuOption(static_cast(nID),nLoc,bcsubs,bclocs); + else + psubmenu=nullptr; + }while(psubmenu != nullptr); + return !!CMenu::ModifyMenu(static_cast(nID),mdata->nFlags, static_cast(nID),(LPCTSTR)mdata); } -BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CImageList *il,int xoffset) +bool BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CImageList *il,int xoffset) { UINT nLoc; BCMenuData *mdata; @@ -955,22 +975,22 @@ BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CImageList *il,int xo // Find the old BCMenuData structure: BCMenu *psubmenu = FindMenuOption(static_cast(nID),nLoc); do{ - if(psubmenu && nLoc!=-1)mdata = psubmenu->m_MenuList[nLoc]; + if(psubmenu != nullptr && nLoc!=-1)mdata = psubmenu->m_MenuList[nLoc]; else{ // Create a new BCMenuData structure: mdata = new BCMenuData; m_MenuList.Add(mdata); } - ASSERT(mdata); - if(lpstrText) + ASSERT(mdata != nullptr); + if(lpstrText != nullptr) mdata->SetWideString(lpstrText); //SK: modified for dynamic allocation mdata->menuIconNormal = -1; mdata->xoffset = -1; - if(il){ - if(mdata->bitmap){ + if(il != nullptr){ + if(mdata->bitmap != nullptr){ mdata->bitmap->DeleteImageList(); - mdata->bitmap=NULL; + mdata->bitmap=nullptr; } mdata->global_offset = AddToGlobalImageList(il,xoffset, static_cast(nID)); } @@ -979,13 +999,15 @@ BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CImageList *il,int xo mdata->nID = nID; bcsubs.Add(psubmenu); bclocs.Add(nLoc); - if(psubmenu && nLoc!=-1)psubmenu = FindAnotherMenuOption(static_cast(nID),nLoc,bcsubs,bclocs); - else psubmenu=NULL; - }while(psubmenu); - return (CMenu::ModifyMenu(static_cast(nID),mdata->nFlags,nID,(LPCTSTR)mdata)); + if(psubmenu!=nullptr && nLoc!=-1) + psubmenu = FindAnotherMenuOption(static_cast(nID),nLoc,bcsubs,bclocs); + else + psubmenu=nullptr; + }while(psubmenu != nullptr); + return !!CMenu::ModifyMenu(static_cast(nID),mdata->nFlags,nID,(LPCTSTR)mdata); } -BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CBitmap *bmp) +bool BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CBitmap *bmp) { if(bmp){ CImageList temp; @@ -994,62 +1016,64 @@ BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CBitmap *bmp) else temp.Add(bmp,GetSysColor(COLOR_3DFACE)); return ModifyODMenuW(lpstrText,nID,&temp,0); } - return ModifyODMenuW(lpstrText,nID,NULL,0); + return ModifyODMenuW(lpstrText,nID,nullptr,0); } -BOOL BCMenu::ModifyODMenuW(wchar_t *lpstrText,wchar_t *OptionText, +bool BCMenu::ModifyODMenuW(wchar_t *lpstrText,wchar_t *OptionText, int nIconNormal) { BCMenuData *mdata; // Find the old BCMenuData structure: mdata=FindMenuOption(OptionText); - if(mdata){ - if(lpstrText) + if(mdata != nullptr){ + if(lpstrText != nullptr) mdata->SetWideString(lpstrText);//SK: modified for dynamic allocation mdata->menuIconNormal = nIconNormal; mdata->xoffset=-1; if(nIconNormal>=0){ mdata->xoffset=0; - if(mdata->bitmap)mdata->bitmap->DeleteImageList(); - else mdata->bitmap=new(CImageList); + if(mdata->bitmap != nullptr) + mdata->bitmap->DeleteImageList(); + else + mdata->bitmap=new(CImageList); mdata->bitmap->Create(m_iconX,m_iconY,ILC_COLORDDB|ILC_MASK,1,1); if(!AddBitmapToImageList(mdata->bitmap,nIconNormal)){ mdata->bitmap->DeleteImageList(); delete mdata->bitmap; - mdata->bitmap=NULL; + mdata->bitmap=nullptr; mdata->menuIconNormal = nIconNormal = -1; mdata->xoffset = -1; } } - return(TRUE); + return true; } - return(FALSE); + return false; } -BOOL BCMenu::SetImageForPopupFromToolbarW (wchar_t *strPopUpText, UINT toolbarID, UINT command_id_to_extract_icon_from) +bool BCMenu::SetImageForPopupFromToolbarW (wchar_t *strPopUpText, UINT toolbarID, UINT command_id_to_extract_icon_from) { CWnd* pWnd = AfxGetMainWnd(); - if (pWnd == NULL)pWnd = CWnd::GetDesktopWindow(); + if (pWnd == nullptr)pWnd = CWnd::GetDesktopWindow(); CToolBar bar; bar.Create(pWnd); if(bar.LoadToolBar(toolbarID)){ BCMenuData *mdata = FindMenuOption(strPopUpText); - if (mdata != NULL) + if (mdata != nullptr) { - if (mdata->bitmap != NULL){ + if (mdata->bitmap != nullptr){ mdata->bitmap->DeleteImageList(); delete mdata->bitmap; - mdata->bitmap=NULL; + mdata->bitmap=nullptr; } CImageList imglist; imglist.Create(m_iconX,m_iconY,ILC_COLORDDB|ILC_MASK,1,1); if(AddBitmapToImageList (&imglist, toolbarID)){ int ind = bar.CommandToIndex (command_id_to_extract_icon_from); - if (ind < 0) { return FALSE; } + if (ind < 0) { return false; } UINT dummyID, dummyStyle; int image_index; @@ -1063,7 +1087,7 @@ BOOL BCMenu::SetImageForPopupFromToolbarW (wchar_t *strPopUpText, UINT toolbarID mdata->menuIconNormal = toolbarID; mdata->xoffset = 0; - return TRUE; + return true; } else{ mdata->menuIconNormal = -1; @@ -1072,7 +1096,7 @@ BOOL BCMenu::SetImageForPopupFromToolbarW (wchar_t *strPopUpText, UINT toolbarID } } - return FALSE; + return false; } @@ -1091,32 +1115,33 @@ BCMenuData *BCMenu::NewODMenu(UINT pos,UINT nFlags,UINT_PTR nID,CString string) mdata->nFlags = nFlags; mdata->nID = nID; -// if(nFlags & MF_POPUP)m_AllSubMenus.Add((HMENU)nID); +// if((nFlags & MF_POPUP)!=0)m_AllSubMenus.Add((HMENU)nID); - if (nFlags&MF_OWNERDRAW){ - ASSERT(!(nFlags&MF_STRING)); + if ((nFlags&MF_OWNERDRAW)!=0){ + ASSERT((nFlags&MF_STRING) == 0); ModifyMenu(pos,nFlags,nID,(LPCTSTR)mdata); } - else if (nFlags&MF_STRING){ - ASSERT(!(nFlags&MF_OWNERDRAW)); + else + if ((nFlags&MF_STRING)!=0){ + ASSERT((nFlags&MF_OWNERDRAW) == 0); ModifyMenu(pos,nFlags,nID,mdata->GetString()); } else{ - ASSERT(nFlags&MF_SEPARATOR); + ASSERT((nFlags&MF_SEPARATOR) != 0); ModifyMenu(pos,nFlags,nID); } - return(mdata); + return mdata; }; bool BCMenu::LoadToolbars(const UINT *arID,int n) { - ASSERT(arID); + ASSERT(arID != nullptr); bool returnflag=true; for(int i=0;i=0){ UINT nStyle; @@ -1143,12 +1167,12 @@ bool BCMenu::LoadToolbar(UINT nToolBar) bar.GetButtonInfo(xoffset,nID,nStyle,xset); if(xset>0)xoffset=xset; } - ModifyODMenu(NULL,nID,&imglist,xoffset); + ModifyODMenu(nullptr,nID,&imglist,xoffset); } } } } - return(returnflag); + return returnflag; } bool BCMenu::LoadFromToolBar(UINT nID,UINT nToolBar,int& xoffset) @@ -1156,14 +1180,14 @@ bool BCMenu::LoadFromToolBar(UINT nID,UINT nToolBar,int& xoffset) // Optimization: avoid creating toolbar window if not needed HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(nID), RT_TOOLBAR); HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(nID), RT_TOOLBAR); - if (hRsrc == NULL) + if (hRsrc == nullptr) return false; bool returnflag=false; CToolBar bar; CWnd* pWnd = AfxGetMainWnd(); - if (pWnd == NULL)pWnd = CWnd::GetDesktopWindow(); + if (pWnd == nullptr)pWnd = CWnd::GetDesktopWindow(); bar.Create(pWnd); if(bar.LoadToolBar(nToolBar)){ int offset=bar.CommandToIndex(nID); @@ -1175,13 +1199,13 @@ bool BCMenu::LoadFromToolBar(UINT nID,UINT nToolBar,int& xoffset) returnflag=true; } } - return(returnflag); + return returnflag; } // O.S. BCMenuData *BCMenu::FindMenuItem(UINT_PTR nID) { - BCMenuData *pData = NULL; + BCMenuData *pData = nullptr; int i; for(i = 0; i <= m_MenuList.GetUpperBound(); i++){ @@ -1190,7 +1214,7 @@ BCMenuData *BCMenu::FindMenuItem(UINT_PTR nID) break; } } - if (!pData){ + if (pData == nullptr){ UINT loc; BCMenu *pMenu = FindMenuOption(static_cast(nID), loc); ASSERT(pMenu != this); @@ -1208,7 +1232,7 @@ BCMenu *BCMenu::FindAnotherMenuOption(int nId,UINT& nLoc,CArray int i; INT_PTR j; BCMenu *psubmenu,*pgoodmenu; - BOOL foundflag; + bool foundflag; for(i=0;i #else psubmenu=static_cast(GetSubMenu((int)i)); #endif - if(psubmenu){ + if(psubmenu != nullptr){ pgoodmenu=psubmenu->FindAnotherMenuOption(nId,nLoc,bcsubs,bclocs); if(pgoodmenu != nullptr) return pgoodmenu; } else if(nId==(int)GetMenuItemID(i)){ INT_PTR numsubs=bcsubs.GetSize(); - foundflag=TRUE; + foundflag=true; for(j=0;j(i)){ - foundflag=FALSE; + foundflag=false; break; } } @@ -1250,7 +1274,7 @@ BCMenu *BCMenu::FindMenuOption(int nId,UINT& nLoc) #else psubmenu=static_cast(GetSubMenu(i)); #endif - if(psubmenu){ + if(psubmenu != nullptr){ pgoodmenu=psubmenu->FindMenuOption(nId,nLoc); if(pgoodmenu != nullptr) return pgoodmenu; @@ -1285,7 +1309,7 @@ BCMenuData *BCMenu::FindMenuOption(wchar_t *lpstrText) for(j=0;j<=m_MenuList.GetUpperBound();++j){ const wchar_t *szWide;//SK: we use const to prevent misuse of this Ptr szWide = m_MenuList[j]->GetWideString (); - if(szWide && !wcscmp(lpstrText,szWide))//SK: modified for dynamic allocation + if(szWide != nullptr && wcscmp(lpstrText,szWide)==0)//SK: modified for dynamic allocation return m_MenuList[j]; } } @@ -1296,7 +1320,7 @@ BCMenuData *BCMenu::FindMenuOption(wchar_t *lpstrText) BOOL BCMenu::LoadMenu(int nResource) { - return(BCMenu::LoadMenu(MAKEINTRESOURCE(nResource))); + return BCMenu::LoadMenu(MAKEINTRESOURCE(nResource)); }; BOOL BCMenu::LoadMenu(LPCTSTR lpszResourceName) @@ -1341,21 +1365,21 @@ BOOL BCMenu::LoadMenu(LPCTSTR lpszResourceName) WORD dwFlags = 0; // Flags of the Menu Item WORD dwID = 0; // ID of the Menu Item CTypedPtrArray stack; // Popup menu stack - CArray stackEnd; // Popup menu stack + CArray stackEnd; // Popup menu stack stack.Add(this); // Add it to this... - stackEnd.Add(FALSE); + stackEnd.Add(false); do{ // Obtain Flags and (if necessary), the ID... memcpy(&dwFlags, pTp, sizeof(WORD));pTp+=sizeof(WORD);// Obtain Flags - if(!(dwFlags & MF_POPUP)){ + if((dwFlags & MF_POPUP)==0){ memcpy(&dwID, pTp, sizeof(WORD)); // Obtain ID pTp+=sizeof(WORD); } else dwID = 0; UINT uFlags = (UINT)dwFlags; // Remove MF_END from the flags that will - if(uFlags & MF_END) // be passed to the Append(OD)Menu functions. + if((uFlags & MF_END) != 0) // be passed to the Append(OD)Menu functions. uFlags -= MF_END; // Obtain Caption (and length) @@ -1368,8 +1392,9 @@ BOOL BCMenu::LoadMenu(LPCTSTR lpszResourceName) // Handle popup menus first.... //WideCharToMultiByte - if(dwFlags & MF_POPUP){ - if(dwFlags & MF_END)stackEnd.SetAt(stack.GetUpperBound(),TRUE); + if((dwFlags & MF_POPUP)!=0){ + if((dwFlags & MF_END)!=0) + stackEnd.SetAt(stack.GetUpperBound(),true); BCMenu* pSubMenu = new BCMenu; pSubMenu->CreatePopupMenu(); @@ -1378,12 +1403,13 @@ BOOL BCMenu::LoadMenu(LPCTSTR lpszResourceName) stack[stack.GetUpperBound()]->AppendODMenuW(szCaption,uFlags, (UINT_PTR)pSubMenu->m_hMenu, -1); stack.Add(pSubMenu); - stackEnd.Add(FALSE); + stackEnd.Add(false); } else { stack[stack.GetUpperBound()]->AppendODMenuW(szCaption, uFlags, dwID, -1); - if(dwFlags & MF_END)stackEnd.SetAt(stack.GetUpperBound(),TRUE); + if((dwFlags & MF_END)!=0) + stackEnd.SetAt(stack.GetUpperBound(),true); j = stack.GetUpperBound(); while(j>=0 && stackEnd.GetAt(j)){ stack.RemoveAt(j); @@ -1408,14 +1434,14 @@ BOOL BCMenu::LoadMenu(LPCTSTR lpszResourceName) } } - m_loadmenu=TRUE; + m_loadmenu=true; - return(TRUE); + return TRUE; } int BCMenu::GetMenuStart(void) { - if(!m_loadmenu)return(0); + if(!m_loadmenu)return 0; CString name,str; int menuloc=-1,listloc=-1,menustart=0,i=0,j=0; @@ -1437,7 +1463,7 @@ int BCMenu::GetMenuStart(void) ++i; } if(menuloc>=0&&listloc>=0&&menuloc>=listloc)menustart=menuloc-listloc; - return(menustart); + return menustart; } void BCMenu::RemoveTopLevelOwnerDraw(void) @@ -1462,23 +1488,24 @@ void BCMenu::RemoveTopLevelOwnerDraw(void) //-------------------------------------------------------------------------- //[18.06.99 rj] -BOOL BCMenu::GetMenuText(UINT id, CString& string, UINT nFlags/*= MF_BYPOSITION*/) +bool BCMenu::GetMenuText(UINT id, CString& string, UINT nFlags/*= MF_BYPOSITION*/) { - BOOL returnflag=FALSE; + bool returnflag=false; - if(MF_BYPOSITION&nFlags){ + if((MF_BYPOSITION&nFlags) != 0){ INT_PTR numMenuItems = m_MenuList.GetUpperBound(); if(static_cast(id)<=numMenuItems){ string=m_MenuList[id]->GetString(); - returnflag=TRUE; + returnflag=true; } } else{ UINT uiLoc; BCMenu* pMenu = FindMenuOption(id,uiLoc); - if(pMenu != nullptr) returnflag = pMenu->GetMenuText(uiLoc,string); + if(pMenu != nullptr) + returnflag = pMenu->GetMenuText(uiLoc,string); } - return(returnflag); + return returnflag; } @@ -1494,7 +1521,7 @@ void BCMenu::DrawRadioDot(CDC *pDC,int x,int y,COLORREF color) pDC->SelectObject(pOldPen); } -void BCMenu::DrawCheckMark(CDC* pDC,int x,int y,COLORREF color,BOOL narrowflag) +void BCMenu::DrawCheckMark(CDC* pDC,int x,int y,COLORREF color,bool narrowflag /*= false*/) { int dp=0; CPen penBack(PS_SOLID,0,color); @@ -1545,7 +1572,7 @@ void BCMenu::InitializeMenuList(int value) void BCMenu::DeleteMenuList(void) { for(int i=0;i<=m_MenuList.GetUpperBound();++i){ - if(!m_MenuList[i]->syncflag){ + if(m_MenuList[i]->syncflag==0){ delete m_MenuList[i]; } } @@ -1559,13 +1586,13 @@ void BCMenu::SynchronizeMenu(void) InitializeMenuList(0); for(int j=0;jm_hMenu; mdata=FindMenuList(submenu); GetMenuString(j,string,MF_BYPOSITION); - if(!mdata)mdata=NewODMenu(j, + if(mdata == nullptr)mdata=NewODMenu(j, (state&0xFF)|MF_BYPOSITION|MF_POPUP|MF_OWNERDRAW,submenu,string); else if(string.GetLength()>0) #ifdef UNICODE @@ -1574,9 +1601,10 @@ void BCMenu::SynchronizeMenu(void) mdata->SetAnsiString(string); #endif } - else if(state&MF_SEPARATOR){ + else + if((state&MF_SEPARATOR)!=0){ mdata=FindMenuList(0); - if(!mdata)mdata=NewODMenu(j, + if(mdata == nullptr)mdata=NewODMenu(j, state|MF_BYPOSITION|MF_SEPARATOR|MF_OWNERDRAW,0,_T(""));//SK: modified for Unicode correctness else ModifyMenu(j,mdata->nFlags,nID,(LPCTSTR)mdata); } @@ -1584,7 +1612,7 @@ void BCMenu::SynchronizeMenu(void) nID=GetMenuItemID(j); mdata=FindMenuList(nID); GetMenuString(j,string,MF_BYPOSITION); - if(!mdata)mdata=NewODMenu(j,state|MF_BYPOSITION|MF_OWNERDRAW, + if(mdata == nullptr)mdata=NewODMenu(j,state|MF_BYPOSITION|MF_OWNERDRAW, nID,string); else{ mdata->nFlags=state|MF_BYPOSITION|MF_OWNERDRAW; @@ -1598,7 +1626,7 @@ void BCMenu::SynchronizeMenu(void) ModifyMenu(j,mdata->nFlags,nID,(LPCTSTR)mdata); } } - if(mdata)temp.Add(mdata); + if(mdata != nullptr)temp.Add(mdata); } DeleteMenuList(); m_MenuList.RemoveAll(); @@ -1613,7 +1641,7 @@ void BCMenu::UpdateMenu(CMenu *pmenu) #else BCMenu *psubmenu = static_cast(pmenu); #endif - if(psubmenu)psubmenu->SynchronizeMenu(); + if(psubmenu != nullptr)psubmenu->SynchronizeMenu(); } LRESULT BCMenu::FindKeyboardShortcut(UINT nChar, UINT nFlags, @@ -1624,7 +1652,7 @@ LRESULT BCMenu::FindKeyboardShortcut(UINT nChar, UINT nFlags, #else BCMenu *pBCMenu = static_cast(pMenu); #endif - if(pBCMenu && nFlags&MF_POPUP){ + if(pBCMenu!=nullptr && (nFlags&MF_POPUP)!=0){ CString key(_T('&'),2);//SK: modified for Unicode correctness key.SetAt(1,(TCHAR)nChar); key.MakeLower(); @@ -1635,11 +1663,11 @@ LRESULT BCMenu::FindKeyboardShortcut(UINT nChar, UINT nFlags, for(int i=0;iGetMenuText(i,menutext)){ menutext.MakeLower(); - if(menutext.Find(key)>=0)return(MAKELRESULT(i,2)); + if(menutext.Find(key)>=0)return MAKELRESULT(i,2); } } } - return(0); + return 0; } void BCMenu::GetTransparentBitmap(CBitmap &bmp) @@ -1739,7 +1767,7 @@ bool BCMenu::AddBitmapToImageList(CImageList *bmplist,UINT nResourceID, bool bDi bool bReturn=false; HBITMAP hbmp=LoadSysColorBitmap(nResourceID); - if(hbmp){ + if(hbmp!=nullptr){ CBitmap bmp; bmp.Attach(hbmp); if (bDisabled) @@ -1767,22 +1795,22 @@ bool BCMenu::AddBitmapToImageList(CImageList *bmplist,UINT nResourceID, bool bDi } } } - return(bReturn); + return bReturn; } void BCMenu::SetBitmapBackground(COLORREF color) { m_bitmapBackground=color; - m_bitmapBackgroundFlag=TRUE; + m_bitmapBackgroundFlag=true; } void BCMenu::UnSetBitmapBackground(void) { - m_bitmapBackgroundFlag=FALSE; + m_bitmapBackgroundFlag=false; } -BOOL BCMenu::Draw3DCheckmark(CDC *dc, const CRect& rc, - BOOL bSelected, HBITMAP hbmCheck) +bool BCMenu::Draw3DCheckmark(CDC *dc, const CRect& rc, + bool bSelected, HBITMAP hbmCheck) { CRect rcDest = rc; COLORREF col=GetSysColor(COLOR_MENU); @@ -1790,9 +1818,11 @@ BOOL BCMenu::Draw3DCheckmark(CDC *dc, const CRect& rc, CBrush cbTemp = col; dc->FillRect(rcDest, &cbTemp); dc->DrawEdge(&rcDest, BDR_SUNKENOUTER, BF_RECT); - if (!hbmCheck)DrawCheckMark(dc,rc.left+4,rc.top+4,GetSysColor(COLOR_MENUTEXT)); - else DrawRadioDot(dc,rc.left+5,rc.top+4,GetSysColor(COLOR_MENUTEXT)); - return TRUE; + if (hbmCheck == nullptr) + DrawCheckMark(dc,rc.left+4,rc.top+4,GetSysColor(COLOR_MENUTEXT)); + else + DrawRadioDot(dc,rc.left+5,rc.top+4,GetSysColor(COLOR_MENUTEXT)); + return true; } void BCMenu::DitherBlt2(CDC *drawdc, int nXDest, int nYDest, int nWidth, @@ -1902,14 +1932,14 @@ HBITMAP BCMenu::LoadSysColorBitmap(int nResourceId) if(numcol!=16) return nullptr; - return AfxLoadSysColorBitmap(hInst, hRsrc, FALSE); + return ::AfxLoadSysColorBitmap(hInst, hRsrc, FALSE); } -BOOL BCMenu::RemoveMenu(UINT uiId,UINT nFlags) +bool BCMenu::RemoveMenu(UINT uiId,UINT nFlags) { if(MF_BYPOSITION&nFlags){ UINT uint = GetMenuState(uiId,MF_BYPOSITION); - if(uint&MF_SEPARATOR && !(uint&MF_POPUP)){ + if((uint&MF_SEPARATOR)!=0 && (uint&MF_POPUP)==0){ delete m_MenuList.GetAt(uiId); m_MenuList.RemoveAt(uiId); } @@ -1957,16 +1987,17 @@ BOOL BCMenu::RemoveMenu(UINT uiId,UINT nFlags) // failed to return correct value on call to remove menu as the item was // removed twice. The second time its not found // so a value of 0 was being returned - if(pMenu) return pMenu->RemoveMenu(iPosition,MF_BYPOSITION); // added return + if(pMenu != nullptr) + return pMenu->RemoveMenu(iPosition,MF_BYPOSITION); // added return } - return CMenu::RemoveMenu(uiId,nFlags); + return !!CMenu::RemoveMenu(uiId,nFlags); } -BOOL BCMenu::DeleteMenu(UINT uiId,UINT nFlags) +bool BCMenu::DeleteMenu(UINT uiId,UINT nFlags) { - if(MF_BYPOSITION&nFlags){ + if((MF_BYPOSITION&nFlags)!=0){ UINT uint = GetMenuState(uiId,MF_BYPOSITION); - if(uint&MF_SEPARATOR && !(uint&MF_POPUP)){ + if((uint&MF_SEPARATOR)!=0 && (uint&MF_POPUP)==0){ // make sure it's a separator INT_PTR menulistsize=m_MenuList.GetSize(); if(uiId<(UINT)menulistsize){ @@ -2016,54 +2047,55 @@ BOOL BCMenu::DeleteMenu(UINT uiId,UINT nFlags) else{ UINT iPosition =0; BCMenu* pMenu = FindMenuOption(uiId,iPosition); - if(pMenu)return pMenu->DeleteMenu(iPosition,MF_BYPOSITION); + if(pMenu != nullptr) + return pMenu->DeleteMenu(iPosition,MF_BYPOSITION); } - return(CMenu::DeleteMenu(uiId,nFlags)); + return !!CMenu::DeleteMenu(uiId,nFlags); } -BOOL BCMenu::AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,int nIconNormal) +bool BCMenu::AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem /*= 0*/,const wchar_t *lpszNewItem /*= nullitem*/,int nIconNormal /*= -1*/) { return AppendODMenuW(lpszNewItem,nFlags,nIDNewItem,nIconNormal); } -BOOL BCMenu::AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CImageList *il,int xoffset) +bool BCMenu::AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CImageList *il,int xoffset) { return AppendODMenuW(lpszNewItem,nFlags,nIDNewItem,il,xoffset); } -BOOL BCMenu::AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CBitmap *bmp) +bool BCMenu::AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CBitmap *bmp) { - if(bmp){ + if(bmp != nullptr){ CImageList temp; temp.Create(m_iconX,m_iconY,ILC_COLORDDB|ILC_MASK,1,1); if(m_bitmapBackgroundFlag)temp.Add(bmp,m_bitmapBackground); else temp.Add(bmp,GetSysColor(COLOR_3DFACE)); return AppendODMenuW(lpszNewItem,nFlags,nIDNewItem,&temp,0); } - return AppendODMenuW(lpszNewItem,nFlags,nIDNewItem,NULL,0); + return AppendODMenuW(lpszNewItem,nFlags,nIDNewItem,nullptr,0); } -BOOL BCMenu::InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,int nIconNormal) +bool BCMenu::InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem /*= 0*/,wchar_t *lpszNewItem /*= nullptr*/,int nIconNormal/*= -1*/) { return InsertODMenuW(nPosition,lpszNewItem,nFlags,nIDNewItem,nIconNormal); } -BOOL BCMenu::InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,CImageList *il,int xoffset) +bool BCMenu::InsertMenuW(UINT nPosition, UINT nFlags, UINT_PTR nIDNewItem, wchar_t *lpszNewItem, CImageList *il, int xoffset) { return InsertODMenuW(nPosition,lpszNewItem,nFlags,nIDNewItem,il,xoffset); } -BOOL BCMenu::InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,CBitmap *bmp) +bool BCMenu::InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,CBitmap *bmp) { - if(bmp){ + if(bmp != nullptr){ CImageList temp; temp.Create(m_iconX,m_iconY,ILC_COLORDDB|ILC_MASK,1,1); if(m_bitmapBackgroundFlag)temp.Add(bmp,m_bitmapBackground); else temp.Add(bmp,GetSysColor(COLOR_3DFACE)); return InsertODMenuW(nPosition,lpszNewItem,nFlags,nIDNewItem,&temp,0); } - return InsertODMenuW(nPosition,lpszNewItem,nFlags,nIDNewItem,NULL,0); + return InsertODMenuW(nPosition,lpszNewItem,nFlags,nIDNewItem,nullptr,0); } //-------------------------------------------------------------------------- @@ -2078,16 +2110,16 @@ BCMenu* BCMenu::AppendODPopupMenuW(const wchar_t *lpstrText) //-------------------------------------------------------------------------- //[21.06.99 rj] -BOOL BCMenu::ImageListDuplicate(CImageList *il,int xoffset,CImageList *newlist) +bool BCMenu::ImageListDuplicate(CImageList *il,int xoffset,CImageList *newlist) { - if (il == NULL||newlist==NULL||xoffset<0) return FALSE; + if (il==nullptr || newlist==nullptr || xoffset<0) return false; HICON hIcon = il->ExtractIcon(xoffset); int cx, cy; ImageList_GetIconSize(il->m_hImageList, &cx, &cy); newlist->Create(cx,cy,ILC_COLORDDB|ILC_MASK,1,1); newlist->Add(hIcon); ::DestroyIcon(hIcon); - return TRUE; + return true; } // 2001-07-12, Damir Valiulin: @@ -2113,22 +2145,23 @@ CMenu* BCMenu::GetSubMenu(LPCTSTR lpszSubMenuName) } } - return NULL; + return nullptr; } BCMenu* BCMenu::GetSubBCMenu(wchar_t* lpszSubMenuName) { BCMenuData *mdata; mdata=FindMenuOption(lpszSubMenuName); - if(mdata){ + if(mdata != nullptr){ HMENU bchmenu=(HMENU)mdata->nID; CMenu *ptr=FromHandle(bchmenu); - if(ptr){ - BOOL flag=ptr->IsKindOf(RUNTIME_CLASS( BCMenu )); - if(flag)return(static_cast(ptr)); + if(ptr!=nullptr){ + bool flag = !!ptr->IsKindOf(RUNTIME_CLASS( BCMenu )); + if(flag) + return static_cast(ptr); } } - return NULL; + return nullptr; } @@ -2140,13 +2173,13 @@ int BCMenu::GetMenuPosition(wchar_t* pText) for(i=0;i(GetSubMenu(i)); - if(!psubmenu) + if(psubmenu == nullptr) { for(j=0;j<=m_MenuList.GetUpperBound();++j) { const wchar_t *szWide;//SK: we use const to prevent misuse of this Ptr szWide = m_MenuList[j]->GetWideString (); - if(szWide && !wcscmp(pText,szWide))//SK: modified for dynamic allocation + if(szWide != nullptr && wcscmp(pText,szWide)==0)//SK: modified for dynamic allocation return j; } } @@ -2210,11 +2243,11 @@ int BCMenu::DeleteMenu(wchar_t* pText, BC_Seperator sPos) } // Larry Antram -BOOL BCMenu::SetMenuText(UINT id, CString string, UINT nFlags/*= MF_BYPOSITION*/ ) +bool BCMenu::SetMenuText(UINT id, CString string, UINT nFlags/*= MF_BYPOSITION*/ ) { - BOOL returnflag=FALSE; + bool returnflag=false; - if(MF_BYPOSITION&nFlags) + if((MF_BYPOSITION&nFlags) != 0) { INT_PTR numMenuItems = m_MenuList.GetUpperBound(); if(static_cast(id)<=numMenuItems){ @@ -2223,15 +2256,16 @@ BOOL BCMenu::SetMenuText(UINT id, CString string, UINT nFlags/*= MF_BYPOSITION*/ #else m_MenuList[id]->SetAnsiString(string); #endif - returnflag=TRUE; + returnflag=true; } } else{ UINT uiLoc; BCMenu* pMenu = FindMenuOption(id,uiLoc); - if(pMenu != nullptr) returnflag = pMenu->SetMenuText(uiLoc,string); + if(pMenu != nullptr) + returnflag = pMenu->SetMenuText(uiLoc,string); } - return(returnflag); + return returnflag; } int BCMenu::GlobalImageListOffset(int nID) @@ -2251,11 +2285,11 @@ INT_PTR BCMenu::AddToGlobalImageList(CImageList *il,int xoffset,int nID) { INT_PTR loc = -1; HIMAGELIST hImageList = m_AllImages.m_hImageList; - if(!hImageList){ + if(hImageList == nullptr){ m_AllImages.Create(m_iconX,m_iconY,ILC_COLORDDB|ILC_MASK,1,1); } HICON hIcon = il->ExtractIcon(xoffset); - if(hIcon){ + if(hIcon != nullptr){ CBitmap bmp,bmp2,bmp3; INT_PTR numcurrent=m_AllImagesID.GetSize(); int existsloc = -1; @@ -2283,7 +2317,7 @@ INT_PTR BCMenu::AddToGlobalImageList(int nIconNormal,int nID) { INT_PTR loc = -1; HIMAGELIST hImageList = m_AllImages.m_hImageList; - if(!hImageList){ + if(hImageList == nullptr){ m_AllImages.Create(m_iconX,m_iconY,ILC_COLORDDB|ILC_MASK,1,1); } INT_PTR numcurrent=m_AllImagesID.GetSize(); @@ -2324,8 +2358,8 @@ bool BCMenu::AppendMenu (BCMenu* pMenuToAdd, bool add_separator /*= true*/, int // * Removed bTopLevel stuff because I didn't test it. // Sanity checks - if (pMenuToAdd == NULL || !pMenuToAdd->IsKindOf (RUNTIME_CLASS(BCMenu))){ - ASSERT(FALSE); + if (pMenuToAdd == nullptr || !pMenuToAdd->IsKindOf (RUNTIME_CLASS(BCMenu))){ + ASSERT(false); return false; } @@ -2343,12 +2377,12 @@ bool BCMenu::AppendMenu (BCMenu* pMenuToAdd, bool add_separator /*= true*/, int int last_delete_item = original_num_menu_items - num_items_to_remove_at_end; for (int i=first_delete_item; i>=last_delete_item; i--){ if (!DeleteMenu (i, MF_BYPOSITION)){ - ASSERT(FALSE); // Something went wrong, but not so critical to abort everything. Just stop deleting items. + ASSERT(false); // Something went wrong, but not so critical to abort everything. Just stop deleting items. break; } } }else{ - ASSERT(FALSE); // Number of items to delete is greater than existing number of menu items! + ASSERT(false); // Number of items to delete is greater than existing number of menu items! } } @@ -2370,7 +2404,7 @@ bool BCMenu::AppendMenu (BCMenu* pMenuToAdd, bool add_separator /*= true*/, int BCMenu* pSubMenu = static_cast(pMenuToAdd->GetSubMenu(iLoop)); // Check if we have a sub menu - if (!pSubMenu) + if (pSubMenu == nullptr) { // Normal menu item @@ -2379,7 +2413,7 @@ bool BCMenu::AppendMenu (BCMenu* pMenuToAdd, bool add_separator /*= true*/, int UINT nItemID = pMenuToAdd->GetMenuItemID( iLoop ); if (!AppendMenu( nState, nItemID, sMenuAddString )){ - ASSERT(FALSE); //TRACE( "MergeMenu: AppendMenu failed!\n" ); + ASSERT(false); //TRACE( "MergeMenu: AppendMenu failed!\n" ); return false; } } @@ -2387,8 +2421,8 @@ bool BCMenu::AppendMenu (BCMenu* pMenuToAdd, bool add_separator /*= true*/, int { // Create a new pop-up menu and insert sub-menu's items into it BCMenu* pNewPopupMenu = AppendODPopupMenu (sMenuAddString); - if (pNewPopupMenu == NULL){ - ASSERT(FALSE); //TRACE( "MergeMenu: CreatePopupMenu failed!\n" ); + if (pNewPopupMenu == nullptr){ + ASSERT(false); //TRACE( "MergeMenu: CreatePopupMenu failed!\n" ); return false; } diff --git a/Src/Common/BCMenu.h b/Src/Common/BCMenu.h index 35f6d9b22..30aaf8e2a 100644 --- a/Src/Common/BCMenu.h +++ b/Src/Common/BCMenu.h @@ -32,8 +32,8 @@ class BCMenuData { wchar_t *m_szMenuText; public: - BCMenuData () {menuIconNormal=-1;xoffset=-1;bitmap=NULL;pContext=NULL; - nFlags=0;nID=0;syncflag=0;m_szMenuText=NULL;global_offset=-1;}; + BCMenuData () {menuIconNormal=-1;xoffset=-1;bitmap=nullptr;pContext=nullptr; + nFlags=0;nID=0;syncflag=0;m_szMenuText=nullptr;global_offset=-1;}; void SetAnsiString(LPCSTR szAnsiString) { USES_CONVERSION; @@ -100,38 +100,38 @@ public: static HBITMAP LoadSysColorBitmap(int nResourceId); // functions for appending a menu option, use the AppendMenu call (see above define) - BOOL AppendMenuA(UINT nFlags,UINT_PTR nIDNewItem=0,const char *lpszNewItem=NULL,int nIconNormal=-1) + bool AppendMenuA(UINT nFlags,UINT_PTR nIDNewItem=0,const char *lpszNewItem=nullptr,int nIconNormal=-1) { USES_CONVERSION; return AppendMenuW(nFlags, nIDNewItem, A2W(lpszNewItem), nIconNormal); } - BOOL AppendMenuA(UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CImageList *il,int xoffset) + bool AppendMenuA(UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CImageList *il,int xoffset) { USES_CONVERSION; return AppendMenuW(nFlags,nIDNewItem,A2W(lpszNewItem),il,xoffset); } - BOOL AppendMenuA(UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CBitmap *bmp) + bool AppendMenuA(UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CBitmap *bmp) { USES_CONVERSION; return AppendMenuW(nFlags,nIDNewItem,A2W(lpszNewItem),bmp); } - BOOL AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem=0,const wchar_t *lpszNewItem=NULL,int nIconNormal=-1); - BOOL AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CImageList *il,int xoffset); - BOOL AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CBitmap *bmp); - BOOL AppendODMenuA(LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, + bool AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem=0,const wchar_t *lpszNewItem=nullptr,int nIconNormal=-1); + bool AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CImageList *il,int xoffset); + bool AppendMenuW(UINT nFlags,UINT_PTR nIDNewItem,const wchar_t *lpszNewItem,CBitmap *bmp); + bool AppendODMenuA(LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, int nIconNormal) { USES_CONVERSION; return AppendODMenuW(A2W(lpstrText),nFlags,nID,nIconNormal);//SK: See MFC Tech Note 059 } - BOOL AppendODMenuW(const wchar_t *lpstrText,UINT nFlags = MF_OWNERDRAW,UINT_PTR nID = 0,int nIconNormal = -1); - BOOL AppendODMenuA(LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, + bool AppendODMenuW(const wchar_t *lpstrText,UINT nFlags = MF_OWNERDRAW,UINT_PTR nID = 0,int nIconNormal = -1); + bool AppendODMenuA(LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, CImageList *il,int xoffset) { USES_CONVERSION; return AppendODMenuW(A2W(lpstrText),nFlags,nID,il,xoffset); } - BOOL AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID,CImageList *il,int xoffset); + bool AppendODMenuW(const wchar_t *lpstrText,UINT nFlags,UINT_PTR nID,CImageList *il,int xoffset); bool AppendMenu (BCMenu* pMenuToAdd, bool add_separator = true, int num_items_to_remove_at_end = 0); // for appending a popup menu (see example application) @@ -143,76 +143,76 @@ public: BCMenu* AppendODPopupMenuW(const wchar_t *lpstrText); // functions for inserting a menu option, use the InsertMenu call (see above define) - BOOL InsertMenuA(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CImageList *il,int xoffset) + bool InsertMenuA(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CImageList *il,int xoffset) { USES_CONVERSION; return InsertMenuW(nPosition,nFlags,nIDNewItem,A2W(lpszNewItem),il,xoffset); } - BOOL InsertMenuA(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CBitmap *bmp) + bool InsertMenuA(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,CBitmap *bmp) { USES_CONVERSION; return InsertMenuW(nPosition,nFlags,nIDNewItem,A2W(lpszNewItem),bmp); } - BOOL InsertMenuA(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,int nIconNormal) + bool InsertMenuA(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,const char *lpszNewItem,int nIconNormal) { USES_CONVERSION; return InsertMenuW(nPosition,nFlags,nIDNewItem,A2W(lpszNewItem),nIconNormal); } - BOOL InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem=0,wchar_t *lpszNewItem=NULL,int nIconNormal=-1); - BOOL InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,CImageList *il,int xoffset); - BOOL InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,CBitmap *bmp); - BOOL InsertODMenuA(UINT nPosition,LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, + bool InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem=0,wchar_t *lpszNewItem=nullptr,int nIconNormal=-1); + bool InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,CImageList *il,int xoffset); + bool InsertMenuW(UINT nPosition,UINT nFlags,UINT_PTR nIDNewItem,wchar_t *lpszNewItem,CBitmap *bmp); + bool InsertODMenuA(UINT nPosition,LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, int nIconNormal) { USES_CONVERSION; return InsertODMenuW(nPosition,A2W(lpstrText),nFlags,nID,nIconNormal); } - BOOL InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags = MF_OWNERDRAW,UINT_PTR nID = 0,int nIconNormal = -1); - BOOL InsertODMenuA(UINT nPosition,LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, + bool InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags = MF_OWNERDRAW,UINT_PTR nID = 0,int nIconNormal = -1); + bool InsertODMenuA(UINT nPosition,LPCSTR lpstrText,UINT nFlags,UINT_PTR nID, CImageList *il,int xoffset) { USES_CONVERSION; return InsertODMenuW(nPosition,A2W(lpstrText),nFlags,nID,il,xoffset); } - BOOL InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PTR nID,CImageList *il,int xoffset); + bool InsertODMenuW(UINT nPosition,wchar_t *lpstrText,UINT nFlags,UINT_PTR nID,CImageList *il,int xoffset); // functions for modifying a menu option, use the ModifyODMenu call (see above define) - BOOL ModifyODMenuA(const char * lpstrText,UINT_PTR nID,int nIconNormal) + bool ModifyODMenuA(const char * lpstrText,UINT_PTR nID,int nIconNormal) { USES_CONVERSION; return ModifyODMenuW(A2W(lpstrText),nID,nIconNormal);//SK: see MFC Tech Note 059 } - BOOL ModifyODMenuA(const char * lpstrText,UINT_PTR nID,CImageList *il,int xoffset) + bool ModifyODMenuA(const char * lpstrText,UINT_PTR nID,CImageList *il,int xoffset) { USES_CONVERSION; return ModifyODMenuW(A2W(lpstrText),nID,il,xoffset); } - BOOL ModifyODMenuA(const char *lpstrText,UINT_PTR nID,CBitmap *bmp) + bool ModifyODMenuA(const char *lpstrText,UINT_PTR nID,CBitmap *bmp) { USES_CONVERSION; return ModifyODMenuW(A2W(lpstrText),nID,bmp); } - BOOL ModifyODMenuA(const char *lpstrText,const char *OptionText, + bool ModifyODMenuA(const char *lpstrText,const char *OptionText, int nIconNormal) { USES_CONVERSION; return ModifyODMenuW(A2W(lpstrText),A2W(OptionText),nIconNormal);//SK: see MFC Tech Note 059 } - BOOL ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID=0,int nIconNormal=-1); - BOOL ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CImageList *il,int xoffset); - BOOL ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CBitmap *bmp); - BOOL ModifyODMenuW(wchar_t *lpstrText,wchar_t *OptionText,int nIconNormal); + bool ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID=0,int nIconNormal=-1); + bool ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CImageList *il,int xoffset); + bool ModifyODMenuW(wchar_t *lpstrText,UINT_PTR nID,CBitmap *bmp); + bool ModifyODMenuW(wchar_t *lpstrText,wchar_t *OptionText,int nIconNormal); - BOOL SetImageForPopupFromToolbarA (const char *strPopUpText, UINT toolbarID, UINT command_id_to_extract_icon_from) + bool SetImageForPopupFromToolbarA (const char *strPopUpText, UINT toolbarID, UINT command_id_to_extract_icon_from) { USES_CONVERSION; return SetImageForPopupFromToolbarW(A2W(strPopUpText),toolbarID,command_id_to_extract_icon_from); } - BOOL SetImageForPopupFromToolbarW (wchar_t *strPopUpText, UINT toolbarID, UINT command_id_to_extract_icon_from); + bool SetImageForPopupFromToolbarW (wchar_t *strPopUpText, UINT toolbarID, UINT command_id_to_extract_icon_from); // for deleting and removing menu options - BOOL RemoveMenu(UINT uiId,UINT nFlags); - BOOL DeleteMenu(UINT uiId,UINT nFlags); + bool RemoveMenu(UINT uiId,UINT nFlags); + bool DeleteMenu(UINT uiId,UINT nFlags); // sPos means Seperator's position, since we have no way to find the seperator's position in the menu // we have to specify them when we call the RemoveMenu to make sure the unused seperators are removed; // sPos = None no seperator removal; @@ -238,8 +238,8 @@ public: // function for retrieving and setting a menu options text (use this function // because it is ownerdrawn) - BOOL GetMenuText(UINT id,CString &string,UINT nFlags = MF_BYPOSITION); - BOOL SetMenuText(UINT id,CString string, UINT nFlags = MF_BYPOSITION); + bool GetMenuText(UINT id,CString &string,UINT nFlags = MF_BYPOSITION); + bool SetMenuText(UINT id,CString string, UINT nFlags = MF_BYPOSITION); // Getting a submenu from it's name or position BCMenu* GetSubBCMenu(char* pText) @@ -284,7 +284,7 @@ protected: BCMenu *FindAnotherMenuOption(int nId,UINT& nLoc,CArray&bcsubs, CArray&bclocs); BCMenuData *FindMenuOption(wchar_t *lpstrText); - void DrawCheckMark(CDC* pDC,int x,int y,COLORREF color,BOOL narrowflag=FALSE); + void DrawCheckMark(CDC* pDC,int x,int y,COLORREF color,bool narrowflag=false); void DrawRadioDot(CDC *pDC,int x,int y,COLORREF color); BCMenuData *NewODMenu(UINT pos,UINT nFlags,UINT_PTR nID,CString string); void SynchronizeMenu(void); @@ -292,14 +292,14 @@ protected: void DeleteMenuList(void); BCMenuData *FindMenuList(UINT_PTR nID); void DrawItem_Win9xNT2000 (LPDRAWITEMSTRUCT lpDIS); - BOOL Draw3DCheckmark(CDC *dc, const CRect& rc,BOOL bSelected,HBITMAP hbmCheck); + bool Draw3DCheckmark(CDC *dc, const CRect& rc,bool bSelected,HBITMAP hbmCheck); void DrawItem_Theme (LPDRAWITEMSTRUCT lpDIS); void DitherBlt2(CDC *drawdc, int nXDest, int nYDest, int nWidth, int nHeight, CBitmap &bmp, int nXSrc, int nYSrc,COLORREF bgcolor); void DitherBlt3(CDC *drawdc, int nXDest, int nYDest, int nWidth, int nHeight, CBitmap &bmp,COLORREF bgcolor); - BOOL GetBitmapFromImageList(CDC* pDC,CImageList *imglist,int nIndex,CBitmap &bmp); - BOOL ImageListDuplicate(CImageList *il,int xoffset,CImageList *newlist); + bool GetBitmapFromImageList(CDC* pDC,CImageList *imglist,int nIndex,CBitmap &bmp); + bool ImageListDuplicate(CImageList *il,int xoffset,CImageList *newlist); static WORD NumBitmapColors(LPBITMAPINFOHEADER lpBitmap); void RemoveTopLevelOwnerDraw(void); int GetMenuStart(void); @@ -325,9 +325,9 @@ protected: static int m_iconX; static int m_iconY; COLORREF m_bitmapBackground; - BOOL m_bitmapBackgroundFlag; + bool m_bitmapBackgroundFlag; static bool hicolor_bitmaps; - BOOL m_loadmenu; + bool m_loadmenu; static MARGINS m_marginCheck; static MARGINS m_marginSeparator; static SIZE m_sizeCheck; diff --git a/Src/Common/CMoveConstraint.cpp b/Src/Common/CMoveConstraint.cpp index 5e6ff637c..6d7676d44 100644 --- a/Src/Common/CMoveConstraint.cpp +++ b/Src/Common/CMoveConstraint.cpp @@ -30,7 +30,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace prdlg { // from windowsx.h -#define GetWindowStyle(hwnd) ((DWORD)GetWindowLong(hwnd, GWL_STYLE)) +#define GetWindowStyle(hwnd) ((DWORD)::GetWindowLong(hwnd, GWL_STYLE)) #define MapWindowRect(hwndFrom, hwndTo, lprc) \ MapWindowPoints((hwndFrom), (hwndTo), (POINT *)(lprc), 2) @@ -67,10 +67,10 @@ CMoveConstraint::Constraint::Init() m_fExpandX = 0; m_fAboveY = 0; m_fExpandY = 0; - m_hwndChild = 0; - m_pWnd = 0; + m_hwndChild = nullptr; + m_pWnd = nullptr; // m_rectChildOriginal - m_hwndParent = 0; + m_hwndParent = nullptr; } CMoveConstraint::CMoveConstraint() @@ -248,7 +248,7 @@ CMoveConstraint::ClearMostData() m_nMaxY=0; m_nDelayed=0; // this specifically does NOT touch m_bSubclassed, as a subclass may still be in use - m_pFormView=0; + m_pFormView=nullptr; m_nOrigScrollX=0; m_nOrigScrollY=0; m_fShrinkWidth=0; @@ -383,10 +383,10 @@ CMoveConstraint::CheckDeferredChildren() for (POSITION pos=constraintList.GetHeadPosition(); pos; constraintList.GetNext(pos)) { Constraint & constraint = constraintList.GetAt(pos); - if (constraint.m_hwndChild) + if (constraint.m_hwndChild != nullptr) continue; ASSERT(constraint.m_pWnd != nullptr); - if (constraint.m_pWnd->m_hWnd) + if (constraint.m_pWnd->m_hWnd != nullptr) { constraint.m_hwndChild = constraint.m_pWnd->m_hWnd; InitializeChildConstraintData(m_hwndDlg, constraint); @@ -430,7 +430,7 @@ CMoveConstraint::Resize(HWND hWnd, UINT nType) for (POSITION pos=constraintList.GetHeadPosition(); pos; constraintList.GetNext(pos)) { Constraint & constraint = constraintList.GetAt(pos); - if (!constraint.m_hwndChild) + if (constraint.m_hwndChild == nullptr) continue; CRect rectChildCurrent; @@ -449,7 +449,7 @@ CMoveConstraint::Resize(HWND hWnd, UINT nType) rectChildCurrent.top = (int)(nDelta * constraint.m_fAboveY) + constraint.m_rectChildOriginal.top; rectChildCurrent.bottom = (int)(nDelta * (constraint.m_fAboveY + constraint.m_fExpandY)) + constraint.m_rectChildOriginal.bottom; - SetWindowPos(constraint.m_hwndChild, NULL, rectChildCurrent.left, rectChildCurrent.top + SetWindowPos(constraint.m_hwndChild, nullptr, rectChildCurrent.left, rectChildCurrent.top , rectChildCurrent.Width(), rectChildCurrent.Height(), SWP_NOZORDER+SWP_NOREDRAW); } diff --git a/Src/Common/CMoveConstraint.h b/Src/Common/CMoveConstraint.h index 01ff2b461..ec442bb75 100644 --- a/Src/Common/CMoveConstraint.h +++ b/Src/Common/CMoveConstraint.h @@ -85,7 +85,7 @@ public: CMoveConstraint(); ~CMoveConstraint(); - bool IsInitalized() { return m_hwndDlg!=0; } + bool IsInitalized() { return m_hwndDlg!=nullptr; } // THIS IS THE USUAL ONE // call from InitDialog (dialogs) or InitialUpdate (views) or OnCreate (frames) diff --git a/Src/Common/LanguageSelect.cpp b/Src/Common/LanguageSelect.cpp index f108392a3..ffa42a1eb 100644 --- a/Src/Common/LanguageSelect.cpp +++ b/Src/Common/LanguageSelect.cpp @@ -613,7 +613,7 @@ bool CLanguageSelect::LoadLanguageFile(LANGID wLangId, bool bShowError /*= false size_t size = SizeofResource(m_hCurrentDll, mergepot); const char *data = (const char *)LoadResource(m_hCurrentDll, mergepot); char buf[1024]; - std::string *ps = 0; + std::string *ps = nullptr; std::string msgid; unsigned uid = 0; bool found_uid = false; @@ -644,7 +644,7 @@ bool CLanguageSelect::LoadLanguageFile(LANGID wLangId, bool bShowError /*= false { ps = &msgid; } - if (ps) + if (ps != nullptr) { char *p = strchr(buf, '"'); char *q = strrchr(buf, '"'); @@ -654,7 +654,7 @@ bool CLanguageSelect::LoadLanguageFile(LANGID wLangId, bool bShowError /*= false } else { - ps = 0; + ps = nullptr; // avoid dereference of empty vector or last vector if (found_uid) { @@ -671,7 +671,7 @@ bool CLanguageSelect::LoadLanguageFile(LANGID wLangId, bool bShowError /*= false if (_tfopen_s(&f, strPath.c_str(), _T("r")) != 0) { FreeLibrary(m_hCurrentDll); - m_hCurrentDll = 0; + m_hCurrentDll = nullptr; if (bShowError) { String str = _T("Failed to load ") + strPath; @@ -679,7 +679,7 @@ bool CLanguageSelect::LoadLanguageFile(LANGID wLangId, bool bShowError /*= false } return false; } - ps = 0; + ps = nullptr; msgid.erase(); found_uid = false; std::string format; @@ -726,7 +726,7 @@ bool CLanguageSelect::LoadLanguageFile(LANGID wLangId, bool bShowError /*= false } else { - ps = 0; + ps = nullptr; if (!msgid.empty()) unslash(0, msgid); if (msgstr.empty()) @@ -755,7 +755,7 @@ bool CLanguageSelect::LoadLanguageFile(LANGID wLangId, bool bShowError /*= false if (unresolved != 0 || mismatched != 0) { FreeLibrary(m_hCurrentDll); - m_hCurrentDll = 0; + m_hCurrentDll = nullptr; m_map_uid_to_msgid.clear(); m_map_msgid_to_uid.clear(); m_codepage = 0; diff --git a/Src/Common/PreferencesDlg.cpp b/Src/Common/PreferencesDlg.cpp index 91ade33aa..ea32ece9d 100644 --- a/Src/Common/PreferencesDlg.cpp +++ b/Src/Common/PreferencesDlg.cpp @@ -273,21 +273,21 @@ void CPreferencesDlg::ReadOptions(bool bUpdate) if (bUpdate) { - SafeUpdatePage(&m_pageGeneral, FALSE); - SafeUpdatePage(&m_pageMergeColors, FALSE); - SafeUpdatePage(&m_pageTextColors, FALSE); - SafeUpdatePage(&m_pageSyntaxColors, FALSE); - SafeUpdatePage(&m_pageMarkerColors, FALSE); - SafeUpdatePage(&m_pageSystem, FALSE); - SafeUpdatePage(&m_pageCompare, FALSE); - SafeUpdatePage(&m_pageCompareFolder, FALSE); - SafeUpdatePage(&m_pageCompareBinary, FALSE); - SafeUpdatePage(&m_pageCompareImage, FALSE); - SafeUpdatePage(&m_pageEditor, FALSE); - SafeUpdatePage(&m_pageCodepage, FALSE); - SafeUpdatePage(&m_pageArchive, FALSE); - SafeUpdatePage(&m_pageBackups, FALSE); - SafeUpdatePage(&m_pageShell, FALSE); + SafeUpdatePage(&m_pageGeneral, false); + SafeUpdatePage(&m_pageMergeColors, false); + SafeUpdatePage(&m_pageTextColors, false); + SafeUpdatePage(&m_pageSyntaxColors, false); + SafeUpdatePage(&m_pageMarkerColors, false); + SafeUpdatePage(&m_pageSystem, false); + SafeUpdatePage(&m_pageCompare, false); + SafeUpdatePage(&m_pageCompareFolder, false); + SafeUpdatePage(&m_pageCompareBinary, false); + SafeUpdatePage(&m_pageCompareImage, false); + SafeUpdatePage(&m_pageEditor, false); + SafeUpdatePage(&m_pageCodepage, false); + SafeUpdatePage(&m_pageArchive, false); + SafeUpdatePage(&m_pageBackups, false); + SafeUpdatePage(&m_pageShell, false); } } diff --git a/Src/Common/ShellFileOperations.cpp b/Src/Common/ShellFileOperations.cpp index 75a916f3e..29980fc3d 100644 --- a/Src/Common/ShellFileOperations.cpp +++ b/Src/Common/ShellFileOperations.cpp @@ -203,7 +203,7 @@ void ShellFileOperations::Reset() m_bOneToOneMapping = false; m_function = 0; m_flags = 0; - m_parentWindow = NULL; + m_parentWindow = nullptr; m_isCanceled = false; m_sources.clear(); diff --git a/Src/Common/UniFile.cpp b/Src/Common/UniFile.cpp index bea088116..6809793ee 100644 --- a/Src/Common/UniFile.cpp +++ b/Src/Common/UniFile.cpp @@ -188,9 +188,9 @@ UniMemFile::UniMemFile() void UniMemFile::Close() { Clear(); - if (m_base) + if (m_base != nullptr) { - m_base = 0; + m_base = nullptr; } m_data = nullptr; m_current = nullptr; @@ -539,7 +539,7 @@ bool UniMemFile::ReadString(String & line, String & eol, bool * lossy) if (m_unicoding == ucr::NONE) { bool eof = true; - unsigned char *eolptr = 0; + unsigned char *eolptr = nullptr; for (eolptr = m_current; (eolptr - m_base + (m_charsize - 1) < m_filesize); ++eolptr) { if (*eolptr == '\n' || *eolptr == '\r') diff --git a/Src/Common/lwdisp.c b/Src/Common/lwdisp.c index 3dd5888df..a50b3685b 100644 --- a/Src/Common/lwdisp.c +++ b/Src/Common/lwdisp.c @@ -72,7 +72,7 @@ msgbox */ static LPTSTR NTAPI ReportError(HRESULT sc, UINT style) { - LPTCH pc = 0; + LPTCH pc = NULL; FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -80,7 +80,7 @@ static LPTSTR NTAPI ReportError(HRESULT sc, UINT style) MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT), (LPTCH)&pc, 0, NULL ); - if (pc == 0) + if (pc == NULL) { FormatMessage ( @@ -95,7 +95,7 @@ static LPTSTR NTAPI ReportError(HRESULT sc, UINT style) { MessageBox(0, pc, 0, style); LocalFree(pc); - pc = 0; + pc = NULL; } return pc; } @@ -105,7 +105,7 @@ static LPTSTR NTAPI ReportError(HRESULT sc, UINT style) */ static LPTSTR FormatMessageFromString(LPCTSTR format, ...) { - LPTCH pc = 0; + LPTCH pc = NULL; va_list list; va_start(list, format); FormatMessage @@ -146,7 +146,7 @@ LPDISPATCH CreatDispatchBy32BitProxy(LPCTSTR source, LPCWSTR progid) { CLSID clsid; VARIANT v[2], ret; - void *pv = 0; + void *pv = NULL; SCODE sc; wchar_t wpath[512]; @@ -219,10 +219,10 @@ LPDISPATCH CreateDispatchBySourceAndCLSID(LPCTSTR source, CLSID *pObjectCLSID) */ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCWSTR progid) { - void *pv = 0; + void *pv = NULL; SCODE sc; WCHAR wc[320]; - if (source == 0) + if (source == NULL) { CLSID clsid; if (SUCCEEDED(sc=CLSIDFromProgID(progid, &clsid))) @@ -319,12 +319,12 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCWSTR progid) // give it a second try after opening within associated application: SHELLEXECUTEINFO sein; sein.cbSize = sizeof sein; - sein.hwnd = 0; + sein.hwnd = NULL; // SEE_MASK_FLAG_DDEWAIT: wait until application is ready to listen sein.fMask = SEE_MASK_FLAG_DDEWAIT; sein.lpVerb = _T("open"); sein.lpFile = source; - sein.lpParameters = 0; + sein.lpParameters = NULL; sein.lpDirectory = _T("."); sein.nShow = SW_SHOWNORMAL; if (ShellExecuteEx(&sein)) @@ -352,7 +352,7 @@ LPDISPATCH NTAPI CreateDispatchBySource(LPCTSTR source, LPCWSTR progid) MessageBox(0, errorText, 0, MB_ICONSTOP|MB_TASKMODAL); LocalFree(errorText); // no valid dispatch - pv = 0; + pv = NULL; } return (LPDISPATCH)pv; } @@ -373,7 +373,7 @@ STDAPI invokeV(LPDISPATCH pi, VARIANT *ret, DISPID id, LPCCH op, VARIANT *argv) dispparams.cNamedArgs = 1; dispparams.rgdispidNamedArgs = &idNamed; } - if (pi) + if (pi != NULL) { BOOL bParamByRef = FALSE; BOOL bNeedToConv = FALSE; @@ -498,7 +498,7 @@ HRESULT invokeW(LPDISPATCH pi, VARIANT *ret, LPCOLESTR silent, LPCCH op, VARIANT { DISPID id = DISPID_UNKNOWN; LPOLESTR name = (LPOLESTR )((UINT_PTR)silent & ~1); - if (pi) + if (pi != NULL) { HRESULT sc = pi->lpVtbl->GetIDsOfNames(pi, &IID_NULL, &name, 1, 0, &id); if (FAILED(sc)) @@ -507,7 +507,7 @@ HRESULT invokeW(LPDISPATCH pi, VARIANT *ret, LPCOLESTR silent, LPCCH op, VARIANT { ReportError(sc, MB_ICONSTOP); } - pi = 0; + pi = NULL; } } return invokeV(pi, ret, id, op, argv); @@ -732,9 +732,9 @@ const struct LWDispVtbl *NTAPI LWDispSubclass(struct LWDispVtbl *lpVtbl) IDispatch *NTAPI LWDispatch(void *target, const void *disp_map, const struct LWDispVtbl *lpVtbl, struct LWDispatch *This) { - if (lpVtbl == 0) + if (lpVtbl == NULL) lpVtbl = &vtbl; - if (This == 0) + if (This == NULL) This = (struct LWDispatch *)malloc(sizeof(*This)); if (This) { @@ -767,7 +767,7 @@ VARIANT NTAPI LWArgA(LPCSTR cVal) UINT len = lstrlenA(cVal); VARIANT v; VariantInit(&v); - V_VAR(&v,BSTR) = SysAllocStringLen(0, len); + V_VAR(&v,BSTR) = SysAllocStringLen(NULL, len); MultiByteToWideChar(CP_ACP, 0, cVal, -1, V_BSTR(&v), len); return v; } diff --git a/Src/Common/sizecbar.cpp b/Src/Common/sizecbar.cpp index a38368ee2..3e11479fc 100644 --- a/Src/Common/sizecbar.cpp +++ b/Src/Common/sizecbar.cpp @@ -432,7 +432,7 @@ void CSizingControlBar::OnNcCalcSize(BOOL bCalcValidRects, if (IsFloating()) { CFrameWnd* pFrame = GetParentFrame(); - if (pFrame != NULL && + if (pFrame != nullptr && pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd))) { DWORD dwStyle = ::GetWindowLong(pFrame->m_hWnd, GWL_STYLE); @@ -493,10 +493,10 @@ void CSizingControlBar::NcCalcClient(LPRECT pRc, UINT nDockBarID) // make room for edges only if they will be painted if (m_dwSCBStyle & SCBS_SHOWEDGES) rc.DeflateRect( - (m_dwSCBStyle & SCBS_EDGELEFT) ? m_cxEdge : 0, - (m_dwSCBStyle & SCBS_EDGETOP) ? m_cxEdge : 0, - (m_dwSCBStyle & SCBS_EDGERIGHT) ? m_cxEdge : 0, - (m_dwSCBStyle & SCBS_EDGEBOTTOM) ? m_cxEdge : 0); + (m_dwSCBStyle & SCBS_EDGELEFT) != 0 ? m_cxEdge : 0, + (m_dwSCBStyle & SCBS_EDGETOP) != 0 ? m_cxEdge : 0, + (m_dwSCBStyle & SCBS_EDGERIGHT) != 0 ? m_cxEdge : 0, + (m_dwSCBStyle & SCBS_EDGEBOTTOM) != 0 ? m_cxEdge : 0); *pRc = rc; } @@ -528,7 +528,7 @@ void CSizingControlBar::OnNcPaint() mdc.FillRect(rcDraw, CBrush::FromHandle( (HBRUSH) GetClassLongPtr(m_hWnd, GCLP_HBRBACKGROUND))); - if (m_dwSCBStyle & SCBS_SHOWEDGES) + if ((m_dwSCBStyle & SCBS_SHOWEDGES) != 0) { CRect rcEdge; // paint the sizing edges for (int i = 0; i < 4; i++) @@ -813,29 +813,33 @@ bool CSizingControlBar::GetEdgeRect(CRect rcWnd, UINT nHitTest, CRect& rcEdge) { rcEdge = rcWnd; - if (m_dwSCBStyle & SCBS_SHOWEDGES) + if ((m_dwSCBStyle & SCBS_SHOWEDGES) != 0) rcEdge.DeflateRect(1, 1); bool bHorz = IsHorzDocked(); switch (nHitTest) { case HTLEFT: - if (!(m_dwSCBStyle & SCBS_EDGELEFT)) return FALSE; + if ((m_dwSCBStyle & SCBS_EDGELEFT) == 0) + return false; rcEdge.right = rcEdge.left + m_cxEdge; rcEdge.DeflateRect(0, bHorz ? m_cxEdge: 0); break; case HTTOP: - if (!(m_dwSCBStyle & SCBS_EDGETOP)) return FALSE; + if ((m_dwSCBStyle & SCBS_EDGETOP) == 0) + return false; rcEdge.bottom = rcEdge.top + m_cxEdge; rcEdge.DeflateRect(bHorz ? 0 : m_cxEdge, 0); break; case HTRIGHT: - if (!(m_dwSCBStyle & SCBS_EDGERIGHT)) return FALSE; + if ((m_dwSCBStyle & SCBS_EDGERIGHT) == 0) + return false; rcEdge.left = rcEdge.right - m_cxEdge; rcEdge.DeflateRect(0, bHorz ? m_cxEdge: 0); break; case HTBOTTOM: - if (!(m_dwSCBStyle & SCBS_EDGEBOTTOM)) return FALSE; + if ((m_dwSCBStyle & SCBS_EDGEBOTTOM) == 0) + return false; rcEdge.top = rcEdge.bottom - m_cxEdge; rcEdge.DeflateRect(bHorz ? 0 : m_cxEdge, 0); break; diff --git a/Src/CompareEngines/Wrap_DiffUtils.cpp b/Src/CompareEngines/Wrap_DiffUtils.cpp index 791e6af49..908287bda 100644 --- a/Src/CompareEngines/Wrap_DiffUtils.cpp +++ b/Src/CompareEngines/Wrap_DiffUtils.cpp @@ -143,7 +143,7 @@ int DiffUtils::diffutils_compare_files() /* Disconnect them from the rest of the changes, making them a hunk, and remember the rest for next iteration. */ next = end->link; - end->link = 0; + end->link = NULL; #ifdef _DEBUG debug_script(thisob); #endif diff --git a/Src/ConfigLog.cpp b/Src/ConfigLog.cpp index a03c50dd1..9eb45f2e0 100644 --- a/Src/ConfigLog.cpp +++ b/Src/ConfigLog.cpp @@ -171,7 +171,7 @@ static String GetLocaleString(LCID locid, LCTYPE lctype) /** * @brief Write string item */ -void CConfigLog::WriteItem(int indent, const String& key, const TCHAR *value) +void CConfigLog::WriteItem(int indent, const String& key, const TCHAR *value /*= nullptr*/) { String text = strutils::format(value ? _T("%*.0s%s: %s\r\n") : _T("%*.0s%s:\r\n"), indent, key.c_str(), key.c_str(), value); m_pfile->WriteString(text); diff --git a/Src/ConfigLog.h b/Src/ConfigLog.h index 897740940..12235cc0e 100644 --- a/Src/ConfigLog.h +++ b/Src/ConfigLog.h @@ -41,7 +41,7 @@ public: // Implementation methods protected: - void WriteItem(int indent, const String& key, const TCHAR *value = 0); + void WriteItem(int indent, const String& key, const TCHAR *value = nullptr); void WriteItem(int indent, const String& key, const String &str); void WriteItem(int indent, const String& key, long value); void WriteVersionOf1(int indent, const String& path); diff --git a/Src/DiffTextBuffer.cpp b/Src/DiffTextBuffer.cpp index 7e272db97..78911d398 100644 --- a/Src/DiffTextBuffer.cpp +++ b/Src/DiffTextBuffer.cpp @@ -479,7 +479,7 @@ int CDiffTextBuffer::LoadFromFile(LPCTSTR pszFileNameInit, * @return SAVE_DONE or an error code (list in MergeDoc.h) */ int CDiffTextBuffer::SaveToFile (const String& pszFileName, - bool bTempFile, String & sError, PackingInfo * infoUnpacker /*= NULL*/, + bool bTempFile, String & sError, PackingInfo * infoUnpacker /*= nullptr*/, CRLFSTYLE nCrlfStyle /*= CRLF_STYLE_AUTOMATIC*/, bool bClearModifiedFlag /*= true*/, int nStartLine /*= 0*/, int nLines /*= -1*/) diff --git a/Src/DiffTextBuffer.h b/Src/DiffTextBuffer.h index aac764f61..39167b3f8 100644 --- a/Src/DiffTextBuffer.h +++ b/Src/DiffTextBuffer.h @@ -53,7 +53,7 @@ public : LPCTSTR filteredFilenames, bool & readOnly, CRLFSTYLE nCrlfStyle, const FileTextEncoding & encoding, CString &sError); int SaveToFile (const String& pszFileName, bool bTempFile, String & sError, - PackingInfo * infoUnpacker = NULL, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC, + PackingInfo * infoUnpacker = nullptr, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC, bool bClearModifiedFlag = true, int nStartLine = 0, int nLines = -1); ucr::UNICODESET getUnicoding() const { return m_encoding.m_unicoding; } void setUnicoding(ucr::UNICODESET value) { m_encoding.m_unicoding = value; } diff --git a/Src/DiffWrapper.cpp b/Src/DiffWrapper.cpp index 48e9b8f59..5575d87b7 100644 --- a/Src/DiffWrapper.cpp +++ b/Src/DiffWrapper.cpp @@ -185,7 +185,7 @@ void CDiffWrapper::SetTextForAutomaticPrediff(const String &text) { m_sToFindPrediffer = text; } -void CDiffWrapper::SetPrediffer(const PrediffingInfo * prediffer /*=NULL*/) +void CDiffWrapper::SetPrediffer(const PrediffingInfo * prediffer /*= nullptr*/) { // all flags are set correctly during the construction m_infoPrediffer.reset(new PrediffingInfo); @@ -731,9 +731,9 @@ bool CDiffWrapper::RunFileDiff() } } - struct change *script = NULL; - struct change *script10 = NULL; - struct change *script12 = NULL; + struct change *script = nullptr; + struct change *script10 = nullptr; + struct change *script12 = nullptr; DiffFileData diffdata, diffdata10, diffdata12; int bin_flag = 0, bin_flag10 = 0, bin_flag12 = 0; @@ -747,9 +747,9 @@ bool CDiffWrapper::RunFileDiff() } // Compare the files, if no error was found. - // Last param (bin_file) is NULL since we don't + // Last param (bin_file) is `nullptr` since we don't // (yet) need info about binary sides. - bRet = Diff2Files(&script, &diffdata, &bin_flag, NULL); + bRet = Diff2Files(&script, &diffdata, &bin_flag, nullptr); // We don't anymore create diff-files for every rescan. // User can create patch-file whenever one wants to. @@ -779,14 +779,14 @@ bool CDiffWrapper::RunFileDiff() return false; } - bRet = Diff2Files(&script10, &diffdata10, &bin_flag10, NULL); + bRet = Diff2Files(&script10, &diffdata10, &bin_flag10, nullptr); if (!diffdata12.OpenFiles(strFileTemp[1], strFileTemp[2])) { return false; } - bRet = Diff2Files(&script12, &diffdata12, &bin_flag12, NULL); + bRet = Diff2Files(&script12, &diffdata12, &bin_flag12, nullptr); } // First determine what happened during comparison @@ -1111,15 +1111,15 @@ bool CDiffWrapper::Diff2Files(struct change ** diffs, DiffFileData *diffData, void CDiffWrapper::FreeDiffUtilsScript(struct change * & script) { - if (!script) return; - struct change *e=0, *p=0; + if (script == nullptr) return; + struct change *e=nullptr, *p=nullptr; // cleanup the script - for (e = script; e; e = p) + for (e = script; e != nullptr; e = p) { p = e->link; free(e); } - script = 0; + script = nullptr; } /** @@ -1191,7 +1191,7 @@ CDiffWrapper::LoadWinMergeDiffsFromDiffUtilsScript(struct change * script, const /* Disconnect them from the rest of the changes, making them a hunk, and remember the rest for next iteration. */ next = end->link; - end->link = 0; + end->link = nullptr; #ifdef DEBUG debug_script(thisob); #endif @@ -1342,7 +1342,7 @@ CDiffWrapper::LoadWinMergeDiffsFromDiffUtilsScript3( /* Disconnect them from the rest of the changes, making them a hunk, and remember the rest for next iteration. */ next = end->link; - end->link = 0; + end->link = nullptr; #ifdef DEBUG debug_script(thisob); #endif diff --git a/Src/DiffWrapper.h b/Src/DiffWrapper.h index 8a3d3ac7b..c44c5e55b 100644 --- a/Src/DiffWrapper.h +++ b/Src/DiffWrapper.h @@ -169,15 +169,14 @@ public: ~CDiffWrapper(); void SetCreatePatchFile(const String &filename); void SetCreateDiffList(DiffList *diffList); - void SetDiffList(DiffList *diffList); void GetOptions(DIFFOPTIONS *options) const; void SetOptions(const DIFFOPTIONS *options); void SetTextForAutomaticPrediff(const String &text); - void SetPrediffer(const PrediffingInfo * prediffer =NULL); + void SetPrediffer(const PrediffingInfo * prediffer = nullptr); void GetPrediffer(PrediffingInfo * prediffer) const; void SetPatchOptions(const PATCHOPTIONS *options); void SetDetectMovedBlocks(bool bDetectMovedBlocks); - bool GetDetectMovedBlocks() const { return (m_pMovedLines[0] != NULL); } + bool GetDetectMovedBlocks() const { return (m_pMovedLines[0] != nullptr); } void SetAppendFiles(bool bAppendFiles); void SetPaths(const PathContext &files, bool tempPaths); void SetAlternativePaths(const PathContext &altPaths); diff --git a/Src/DirActions.h b/Src/DirActions.h index 74561b45b..93384a63c 100644 --- a/Src/DirActions.h +++ b/Src/DirActions.h @@ -671,8 +671,8 @@ void ApplyPluginPrediffSetting(const InputIterator& begin, const InputIterator& filteredFilenames += ::GetItemFileName(ctxt, di, i); } } - PackingInfo * infoUnpacker = 0; - PrediffingInfo * infoPrediffer = 0; + PackingInfo * infoUnpacker = nullptr; + PrediffingInfo * infoPrediffer = nullptr; const_cast(ctxt).FetchPluginInfos(filteredFilenames, &infoUnpacker, &infoPrediffer); infoPrediffer->Initialize(newsetting); } diff --git a/Src/DirDoc.cpp b/Src/DirDoc.cpp index f82e266cf..b3c5498eb 100644 --- a/Src/DirDoc.cpp +++ b/Src/DirDoc.cpp @@ -77,9 +77,9 @@ CDirDoc::CDirDoc() { m_nDirs = m_nDirsTemp; - m_bRO[0] = FALSE; - m_bRO[1] = FALSE; - m_bRO[2] = FALSE; + m_bRO[0] = false; + m_bRO[1] = false; + m_bRO[2] = false; } /** diff --git a/Src/DirView.cpp b/Src/DirView.cpp index e8f7fbf4d..cf5402aa8 100644 --- a/Src/DirView.cpp +++ b/Src/DirView.cpp @@ -1322,7 +1322,7 @@ static bool CreateFoldersPair(const PathContext& paths) * This handles the case that one item is selected * and the case that two items are selected (one on each side) */ -void CDirView::OpenSelection(SELECTIONTYPE selectionType /*= SELECTIONTYPE_NORMAL*/, PackingInfo * infoUnpacker /*= NULL*/) +void CDirView::OpenSelection(SELECTIONTYPE selectionType /*= SELECTIONTYPE_NORMAL*/, PackingInfo * infoUnpacker /*= nullptr*/) { Merge7zFormatMergePluginScope scope(infoUnpacker); CDirDoc * pDoc = GetDocument(); @@ -2354,7 +2354,7 @@ void CDirView::FixReordering() lvcol.mask = LVCF_ORDER; lvcol.fmt = 0; lvcol.cx = 0; - lvcol.pszText = 0; + lvcol.pszText = nullptr; lvcol.iSubItem = 0; for (int i = 0; i < m_pColItems->GetColCount(); ++i) { @@ -2858,7 +2858,7 @@ void CDirView::OnUpdatePluginPredifferMode(CCmdUI* pCmdUI) pCmdUI->Enable(GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED)); BCMenu *pPopup = static_cast(pCmdUI->m_pSubMenu); - if (pPopup == NULL) + if (pPopup == nullptr) return; std::pair counts = CountPredifferYesNo(SelBegin(), SelEnd(), GetDiffContext()); diff --git a/Src/DirView.h b/Src/DirView.h index 2babeb18e..e95708da4 100644 --- a/Src/DirView.h +++ b/Src/DirView.h @@ -387,7 +387,7 @@ protected: BOOL OnHeaderEndDrag(LPNMHEADER hdr, LRESULT* pResult); private: - void OpenSelection(SELECTIONTYPE selectionType = SELECTIONTYPE_NORMAL, PackingInfo * infoUnpacker = NULL); + void OpenSelection(SELECTIONTYPE selectionType = SELECTIONTYPE_NORMAL, PackingInfo * infoUnpacker = nullptr); void OpenSelectionAs(UINT id); bool GetSelectedItems(int * sel1, int * sel2, int * sel3); void OpenParentDirectory(); diff --git a/Src/DirViewColItems.cpp b/Src/DirViewColItems.cpp index 051ea9a31..e8822f299 100644 --- a/Src/DirViewColItems.cpp +++ b/Src/DirViewColItems.cpp @@ -961,7 +961,7 @@ static int ColEncodingSort(const CDiffContext *, const void *p, const void *q) * - custom function for sorting column data * - parameter for custom functions: DIFFITEM (if NULL) or one of its fields * - default column order number, -1 if not shown by default - * - ascending (TRUE) or descending (FALSE) default sort order + * - ascending (`true`) or descending (`false`) default sort order * - alignment of column contents: numbers are usually right-aligned */ static DirColInfo f_cols[] = diff --git a/Src/EditorFilepathBar.cpp b/Src/EditorFilepathBar.cpp index 86ba48834..13b06c1de 100644 --- a/Src/EditorFilepathBar.cpp +++ b/Src/EditorFilepathBar.cpp @@ -192,10 +192,10 @@ BOOL CEditorFilePathBar::OnToolTipNotify(UINT id, NMHDR * pTTTStruct, LRESULT * // just to do the first time, but how to access the tooltip during init ? ::SendMessage(pTTTStruct->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 5000); - return(TRUE); + return TRUE; } } - return(FALSE); + return FALSE; } void CEditorFilePathBar::OnSetFocusEdit(UINT id) @@ -243,14 +243,14 @@ void CEditorFilePathBar::SetText(int pane, const String& sString) * @brief Set the active status for one status (change the appearance) * * @param [in] pane Index (0-based) of pane to update. - * @param [in] bActive If TRUE activates pane, FALSE deactivates. + * @param [in] bActive If `true` activates pane, `false` deactivates. */ void CEditorFilePathBar::SetActive(int pane, bool bActive) { ASSERT (pane >= 0 && pane < countof(m_Edit)); // Check for NULL since window may be closing.. - if (m_hWnd == NULL) + if (m_hWnd == nullptr) return; m_Edit[pane].SetActive(bActive); diff --git a/Src/FolderCmp.cpp b/Src/FolderCmp.cpp index acd200959..269ac8d0d 100644 --- a/Src/FolderCmp.cpp +++ b/Src/FolderCmp.cpp @@ -93,8 +93,8 @@ int FolderCmp::prepAndCompareFiles(CDiffContext * pCtxt, DIFFITEM &di) // text used for automatic mode : plugin filter must match it String filteredFilenames = strutils::join(tFiles.begin(), tFiles.end(), _T("|")); - PackingInfo * infoUnpacker=0; - PrediffingInfo * infoPrediffer=0; + PackingInfo * infoUnpacker = nullptr; + PrediffingInfo * infoPrediffer = nullptr; // Get existing or new plugin infos if (pCtxt->m_piPluginInfos) diff --git a/Src/HexMergeDoc.cpp b/Src/HexMergeDoc.cpp index b93e116da..38980e5b7 100644 --- a/Src/HexMergeDoc.cpp +++ b/Src/HexMergeDoc.cpp @@ -300,7 +300,7 @@ bool CHexMergeDoc::PromptAndSaveIfNeeded(bool bAllowCancel) } else { - result = FALSE; + result = false; } // If file were modified and saving was successfull, @@ -585,7 +585,7 @@ void CHexMergeDoc::UpdateHeaderPath(int pane) static void Customize(IHexEditorWindow::Settings *settings) { settings->bSaveIni = false; - //settings->iAutomaticBPL = FALSE; + //settings->iAutomaticBPL = false; //settings->iBytesPerLine = 16; //settings->iFontSize = 8; } diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 31430bcc0..175b5fbcd 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -420,11 +420,11 @@ HMENU CMainFrame::GetPrediffersSubmenu(HMENU mainMenu) HMENU CMainFrame::NewMenu(int view, int ID) { int menu_view, index; - if (m_pMenus[view] == NULL) + if (m_pMenus[view] == nullptr) { m_pMenus[view].reset(new BCMenu()); - if (m_pMenus[view] == NULL) - return NULL; + if (m_pMenus[view] == nullptr) + return nullptr; } switch (view) @@ -444,7 +444,7 @@ HMENU CMainFrame::NewMenu(int view, int ID) if (!m_pMenus[view]->LoadMenu(ID)) { ASSERT(false); - return NULL; + return nullptr; } if (view == MENU_IMGMERGEVIEW) @@ -557,7 +557,7 @@ LRESULT CMainFrame::OnMenuChar(UINT nChar, UINT nFlags, lresult=BCMenu::FindKeyboardShortcut(nChar, nFlags, pMenu); else lresult=CMDIFrameWnd::OnMenuChar(nChar, nFlags, pMenu); - return(lresult); + return lresult; } /** @@ -597,8 +597,8 @@ FileLocationGuessEncodings(FileLocation & fileloc, int iGuessEncoding) bool CMainFrame::ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation ifileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*=_T("")*/, - const PackingInfo * infoUnpacker /*= NULL*/) + const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/, + const PackingInfo * infoUnpacker /*= nullptr*/) { int pane; FileFilterHelper filterImg, filterBin; @@ -650,8 +650,8 @@ int GetActivePaneFromFlags(int nFiles, const DWORD dwFlags[]) */ bool CMainFrame::ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation ifileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*=_T("")*/, - const PackingInfo * infoUnpacker /*= NULL*/) + const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/, + const PackingInfo * infoUnpacker /*= nullptr*/) { if (!m_pMenus[MENU_MERGEVIEW]) theApp.m_pDiffTemplate->m_hMenuShared = NewMergeViewMenu(); @@ -736,8 +736,8 @@ bool CMainFrame::ShowMergeDoc(CDirDoc * pDirDoc, } bool CMainFrame::ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*=_T("")*/, - const PackingInfo * infoUnpacker /*= NULL*/) + const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/, + const PackingInfo * infoUnpacker /*= nullptr*/) { if (!m_pMenus[MENU_HEXMERGEVIEW]) theApp.m_pHexMergeTemplate->m_hMenuShared = NewHexMergeViewMenu(); @@ -755,8 +755,8 @@ bool CMainFrame::ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocati } bool CMainFrame::ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*=_T("")*/, - const PackingInfo * infoUnpacker/* = NULL*/) + const DWORD dwFlags[], const String strDesc[], const String& sReportFile /*= _T("")*/, + const PackingInfo * infoUnpacker /*= nullptr*/) { CImgMergeFrame *pImgMergeFrame = new CImgMergeFrame(); if (!CImgMergeFrame::menu.m_hMenu) @@ -882,15 +882,15 @@ static bool AddToRecentDocs(const PathContext& paths, const unsigned flags[], bo * @param [in] prediffer Prediffer plugin name. * @return `true` if opening files and compare succeeded, `false` otherwise. */ -bool CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/, - const DWORD dwFlags[] /*=NULL*/, const String strDesc[] /*=NULL*/, const String& sReportFile /*=T("")*/, bool bRecurse /*= false*/, CDirDoc *pDirDoc/*=NULL*/, - String prediffer /*=_T("")*/, const PackingInfo *infoUnpacker/*=NULL*/) +bool CMainFrame::DoFileOpen(const PathContext * pFiles /*= nullptr*/, + const DWORD dwFlags[] /*= nullptr*/, const String strDesc[] /*= nullptr*/, const String& sReportFile /*= T("")*/, bool bRecurse /*= false*/, CDirDoc *pDirDoc/*= nullptr*/, + String prediffer /*= _T("")*/, const PackingInfo *infoUnpacker /*= nullptr*/) { if (pDirDoc && !pDirDoc->CloseMergeDocs()) - return FALSE; + return false; - FileTransform::g_bUnpackerMode = theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL); - FileTransform::g_bPredifferMode = theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL); + FileTransform::g_eUnpackerMode = static_cast(theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL)); + FileTransform::g_ePredifferMode = static_cast(theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL)); Merge7zFormatMergePluginScope scope(infoUnpacker); @@ -924,7 +924,7 @@ bool CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/, pOpenDoc->m_infoHandler = *infoUnpacker; CFrameWnd *pFrame = theApp.m_pOpenTemplate->CreateNewFrame(pOpenDoc, NULL); theApp.m_pOpenTemplate->InitialUpdateFrame(pFrame, pOpenDoc); - return TRUE; + return true; } else { @@ -1021,7 +1021,7 @@ bool CMainFrame::DoFileOpen(const PathContext * pFiles /*=NULL*/, AddToRecentDocs(*pFiles, (unsigned *)dwFlags, bRecurse, filter); } - return TRUE; + return true; } void CMainFrame::UpdateFont(FRAMETYPE frame) @@ -1452,7 +1452,7 @@ CMergeEditView * CMainFrame::GetActiveMergeEditView() CChildFrame * pFrame = dynamic_cast(GetActiveFrame()); if (!pFrame) return 0; // Try to get the active MergeEditView (ie, left or right) - if (pFrame->GetActiveView() && pFrame->GetActiveView()->IsKindOf(RUNTIME_CLASS(CMergeEditView))) + if (pFrame->GetActiveView() != nullptr && pFrame->GetActiveView()->IsKindOf(RUNTIME_CLASS(CMergeEditView))) { return dynamic_cast(pFrame->GetActiveView()); } diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 14ba00c13..a54e98e39 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -95,16 +95,16 @@ public: void UpdatePrediffersMenu(); void FileNew(int nPanes); - bool DoFileOpen(const PathContext *pFiles = NULL, - const DWORD dwFlags[] = NULL, const String strDesc[] = NULL, const String& sReportFile = _T(""), bool bRecurse = false, CDirDoc *pDirDoc = NULL, String prediffer = _T(""), const PackingInfo * infoUnpacker = NULL); + bool DoFileOpen(const PathContext *pFiles = nullptr, + const DWORD dwFlags[] = nullptr, const String strDesc[] = nullptr, const String& sReportFile = _T(""), bool bRecurse = false, CDirDoc *pDirDoc = nullptr, String prediffer = _T(""), const PackingInfo * infoUnpacker = nullptr); bool ShowAutoMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL); + const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr); bool ShowMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL); + const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr); bool ShowHexMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL); + const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr); bool ShowImgMergeDoc(CDirDoc * pDirDoc, int nFiles, const FileLocation fileloc[], - const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = NULL); + const DWORD dwFlags[], const String strDesc[], const String& sReportFile = _T(""), const PackingInfo * infoUnpacker = nullptr); void UpdateResources(); void ClearStatusbarItemCount(); diff --git a/Src/MergeCmdLineInfo.cpp b/Src/MergeCmdLineInfo.cpp index 1f0af4615..11a3ea396 100644 --- a/Src/MergeCmdLineInfo.cpp +++ b/Src/MergeCmdLineInfo.cpp @@ -42,12 +42,12 @@ * @param [out] flag Tells whether param is the name of a flag. * @return Points to the remaining portion of the command line. */ -const TCHAR *MergeCmdLineInfo::EatParam(const TCHAR *p, String ¶m, bool *flag) +const TCHAR *MergeCmdLineInfo::EatParam(const TCHAR *p, String ¶m, bool *flag /*= nullptr*/) { - if (p && *(p += _tcsspn(p, _T(" \t\r\n"))) == _T('\0')) - p = 0; + if (p != nullptr && *(p += _tcsspn(p, _T(" \t\r\n"))) == _T('\0')) + p = nullptr; const TCHAR *q = p; - if (q) + if (q != nullptr) { TCHAR c = *q; bool quoted = false; @@ -75,11 +75,11 @@ const TCHAR *MergeCmdLineInfo::EatParam(const TCHAR *p, String ¶m, bool *fla else { *flag = false; - flag = 0; + flag = nullptr; } } param.assign(p ? p : _T(""), q - p); - if (q > p && flag) + if (q > p && flag != nullptr) { param = strutils::makelower(param); } diff --git a/Src/MergeCmdLineInfo.h b/Src/MergeCmdLineInfo.h index c476cd58a..4c1aec6fa 100644 --- a/Src/MergeCmdLineInfo.h +++ b/Src/MergeCmdLineInfo.h @@ -92,7 +92,7 @@ public: private: - static const TCHAR *EatParam(const TCHAR *, String &, bool *flag = 0); + static const TCHAR *EatParam(const TCHAR *, String &, bool *flag = nullptr); const TCHAR *SetOption(const TCHAR *, const String& key, const TCHAR *value = _T("1")); const TCHAR *SetConfig(const TCHAR *); void ParseWinMergeCmdLine(const TCHAR *); diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index 9810335f5..580f51142 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -2734,8 +2734,8 @@ bool CMergeDoc::OpenDocs(int nFiles, const FileLocation ifileloc[], } // Define the prediffer - PackingInfo * infoUnpacker = 0; - PrediffingInfo * infoPrediffer = 0; + PackingInfo * infoUnpacker = nullptr; + PrediffingInfo * infoPrediffer = nullptr; if (bFiltersEnabled && m_pDirDoc) { m_pDirDoc->GetPluginManager().FetchPluginInfos(m_strBothFilenames, &infoUnpacker, &infoPrediffer); diff --git a/Src/MovedBlocks.cpp b/Src/MovedBlocks.cpp index 6e4cfb36d..65b39ba7b 100644 --- a/Src/MovedBlocks.cpp +++ b/Src/MovedBlocks.cpp @@ -119,7 +119,7 @@ extern "C" void moved_block_analysis(struct change ** pscript, struct file_data { // scan down block for a match p = e->link; - EqGroup * pgroup = 0; + EqGroup * pgroup = nullptr; int i=0; for (i=e->line0; i-(e->line0) < (e->deleted); ++i) { @@ -132,7 +132,7 @@ extern "C" void moved_block_analysis(struct change ** pscript, struct file_data } // if no match, go to next diff block - if (!pgroup) + if (pgroup == nullptr) continue; // found a match @@ -237,7 +237,7 @@ extern "C" void moved_block_analysis(struct change ** pscript, struct file_data { // scan down block for a match p = e->link; - EqGroup * pgroup = 0; + EqGroup * pgroup = nullptr; int j=0; for (j=e->line1; j-(e->line1) < (e->inserted); ++j) { @@ -250,7 +250,7 @@ extern "C" void moved_block_analysis(struct change ** pscript, struct file_data } // if no match, go to next diff block - if (!pgroup) + if (pgroup == nullptr) continue; // found a match diff --git a/Src/OpenDoc.cpp b/Src/OpenDoc.cpp index 4f5131a2d..8749656c8 100644 --- a/Src/OpenDoc.cpp +++ b/Src/OpenDoc.cpp @@ -13,7 +13,7 @@ IMPLEMENT_DYNCREATE(COpenDoc, CDocument) COpenDoc::COpenDoc() : - m_bRecurse(FALSE) + m_bRecurse(false) , m_dwFlags() { } diff --git a/Src/OpenView.cpp b/Src/OpenView.cpp index d5b85b54d..63adc72f4 100644 --- a/Src/OpenView.cpp +++ b/Src/OpenView.cpp @@ -1184,7 +1184,7 @@ bool COpenView::LoadProjectFile(const String &path) ProjectFile prj; if (!theApp.LoadProjectFile(path, prj)) - return FALSE; + return false; bool recurse; prj.GetPaths(m_files, recurse); @@ -1209,7 +1209,7 @@ bool COpenView::LoadProjectFile(const String &path) if (m_strExt[0] != '*') m_strExt.insert(0, filterPrefix); } - return TRUE; + return true; } /** diff --git a/Src/PatchHTML.cpp b/Src/PatchHTML.cpp index 5e64e2d82..0d1f96f80 100644 --- a/Src/PatchHTML.cpp +++ b/Src/PatchHTML.cpp @@ -368,7 +368,7 @@ mark_ignorable (struct change *script) int first0, last0, first1, last1, deletes, inserts; /* Turn this change into a hunk: detach it from the others. */ - script->link = 0; + script->link = NULL; /* Determine whether this change is ignorable. */ analyze_hunk (script, &first0, &last0, &first1, &last1, &deletes, &inserts, files); diff --git a/Src/PluginManager.cpp b/Src/PluginManager.cpp index 581696f0e..9e5e55890 100644 --- a/Src/PluginManager.cpp +++ b/Src/PluginManager.cpp @@ -43,8 +43,8 @@ void PluginManager::FetchPluginInfos(const String& filteredFilenames, */ void PluginManager::SetPrediffSetting(const String& filteredFilenames, int newsetting) { - PackingInfo * infoUnpacker = 0; - PrediffingInfo * infoPrediffer = 0; + PackingInfo * infoUnpacker = nullptr; + PrediffingInfo * infoPrediffer = nullptr; FetchPluginInfos(filteredFilenames, &infoUnpacker, &infoPrediffer); infoPrediffer->Initialize(newsetting); } @@ -63,8 +63,8 @@ void PluginManager::SetPrediffSettingAll(int newsetting) void PluginManager::SetPrediffer(const String& filteredFilenames, const String & prediffer) { - PackingInfo * infoUnpacker = 0; - PrediffingInfo * infoPrediffer = 0; + PackingInfo * infoUnpacker = nullptr; + PrediffingInfo * infoPrediffer = nullptr; FetchPluginInfos(filteredFilenames, &infoUnpacker, &infoPrediffer); infoPrediffer->pluginName = prediffer; } \ No newline at end of file diff --git a/Src/Plugins.cpp b/Src/Plugins.cpp index d19c6d0a3..242a4a4c4 100644 --- a/Src/Plugins.cpp +++ b/Src/Plugins.cpp @@ -120,12 +120,12 @@ int GetFunctionsFromScript(IDispatch *piDispatch, vector& namesArray, ve UINT iValidFunc = 0; if (piDispatch) { - ITypeInfo *piTypeInfo=0; + ITypeInfo *piTypeInfo=nullptr; unsigned iTInfo = 0; // 0 for type information of IDispatch itself LCID lcid=0; // locale for localized method names (ignore if no localized names) if (SUCCEEDED(piDispatch->GetTypeInfo(iTInfo, lcid, &piTypeInfo))) { - TYPEATTR *pTypeAttr=0; + TYPEATTR *pTypeAttr=nullptr; if (SUCCEEDED(piTypeInfo->GetTypeAttr(&pTypeAttr))) { // allocate arrays for the returned structures diff --git a/Src/Plugins.h b/Src/Plugins.h index 9eba724b3..e76cc9df6 100644 --- a/Src/Plugins.h +++ b/Src/Plugins.h @@ -50,7 +50,7 @@ class PluginInfo { public: PluginInfo() - : m_lpDispatch(NULL), m_filters(NULL), m_bAutomatic(false), m_nFreeFunctions(0), m_disabled(false) + : m_lpDispatch(nullptr), m_filters(NULL), m_bAutomatic(false), m_nFreeFunctions(0), m_disabled(false) { } diff --git a/Src/codepage_detect.cpp b/Src/codepage_detect.cpp index 1e6c02be7..a1a5ea440 100644 --- a/Src/codepage_detect.cpp +++ b/Src/codepage_detect.cpp @@ -53,7 +53,7 @@ FindEncodingIdFromNameOrAlias(const char *encodingName) if (encodingId == 0) { // Handle purely numeric values (codepages) - char *ahead = 0; + char *ahead = nullptr; unsigned codepage = strtol(encodingName, &ahead, 10); int i = 0; while (*ahead != '\0' && i < sizeof(f_wincp_prefixes)/sizeof(f_wincp_prefixes[0])) diff --git a/Src/diffutils/src/analyze.c b/Src/diffutils/src/analyze.c index c8d091ccf..a2d2284d5 100644 --- a/Src/diffutils/src/analyze.c +++ b/Src/diffutils/src/analyze.c @@ -755,7 +755,7 @@ add_change (int line0, int line1, int deleted, int inserted, struct change *old) static struct change * build_reverse_script (struct file_data const filevec[]) { - struct change *script = 0; + struct change *script = NULL; char *changed0 = filevec[0].changed_flag; char *changed1 = filevec[1].changed_flag; int len0 = filevec[0].buffered_lines; @@ -792,7 +792,7 @@ build_reverse_script (struct file_data const filevec[]) static struct change * build_script (struct file_data const filevec[]) { - struct change *script = 0; + struct change *script = NULL; char *changed0 = filevec[0].changed_flag; char *changed1 = filevec[1].changed_flag; int i0 = filevec[0].buffered_lines, i1 = filevec[1].buffered_lines; @@ -1003,7 +1003,7 @@ struct change * diff_2_files (struct file_data filevec[], int depth, int * bin_s // Disconnect them from the rest of the changes, making them // a hunk, and remember the rest for next iteration. next = end->link; - end->link = 0; + end->link = NULL; // Determine whether thisob hunk is really a difference. analyze_hunk (thisob, &first0, &last0, &first1, &last1, @@ -1019,7 +1019,7 @@ struct change * diff_2_files (struct file_data filevec[], int depth, int * bin_s } else { - changes = (script != 0); + changes = (script != NULL); } /* WinMerge moved block support */ diff --git a/Src/diffutils/src/context.c b/Src/diffutils/src/context.c index 8dc67bcb1..539c22466 100644 --- a/Src/diffutils/src/context.c +++ b/Src/diffutils/src/context.c @@ -77,7 +77,7 @@ print_context_script (struct change *script, int unidiff_flag) else { struct change *e; - for (e = script; e; e = e->link) + for (e = script; e != NULL; e = e->link) e->ignore = 0; } @@ -144,7 +144,7 @@ pr_context_hunk (struct change *hunk) last1 = min (last1 + context, files[1].valid_lines - 1); /* If desired, find the preceding function definition line in file 0. */ - function = 0; + function = NULL; begin_output (); out = outfile; @@ -153,7 +153,7 @@ pr_context_hunk (struct change *hunk) include its name in the header of the diff section. */ fprintf (out, "***************"); - if (function) + if (function != NULL) { fprintf (out, " "); fwrite (function, 1, min (function_length - 1, 40), out); @@ -272,7 +272,7 @@ pr_unidiff_hunk (struct change *hunk) last1 = min (last1 + context, files[1].valid_lines - 1); /* If desired, find the preceding function definition line in file 0. */ - function = 0; + function = NULL; begin_output (); out = outfile; @@ -286,7 +286,7 @@ pr_unidiff_hunk (struct change *hunk) /* If we looked for and found a function this is part of, include its name in the header of the diff section. */ - if (function) + if (function != NULL) { putc (' ', out); fwrite (function, 1, min (function_length - 1, 40), out); @@ -387,7 +387,7 @@ mark_ignorable (struct change *script) int first0, last0, first1, last1, deletes, inserts; /* Turn this change into a hunk: detach it from the others. */ - script->link = 0; + script->link = NULL; /* Determine whether this change is ignorable. */ analyze_hunk (script, &first0, &last0, &first1, &last1, &deletes, &inserts, files); diff --git a/Src/diffutils/src/ifdef.c b/Src/diffutils/src/ifdef.c index 14126f022..d60c5bc00 100644 --- a/Src/diffutils/src/ifdef.c +++ b/Src/diffutils/src/ifdef.c @@ -362,7 +362,7 @@ scan_char_literal (char *lit, int *intptr) { case 0: case '\'': - return 0; + return NULL; case '\\': value = 0; @@ -370,19 +370,19 @@ scan_char_literal (char *lit, int *intptr) { unsigned digit = c - '0'; if (8 <= digit) - return 0; + return NULL; value = 8 * value + digit; } assert((p - lit - 2) < INT_MAX); digits = (int)(p - lit - 2); if (! (1 <= digits && digits <= 3)) - return 0; + return NULL; break; default: value = c; if (*p++ != '\'') - return 0; + return NULL; break; } *intptr = value; @@ -390,7 +390,7 @@ scan_char_literal (char *lit, int *intptr) } /* Scan optional printf-style SPEC of the form `-*[0-9]*(.[0-9]*)?[cdoxX]'. - Return the address of the character following SPEC, or zero if failure. */ + Return the address of the character following SPEC, or NULL if failure. */ static char * scan_printf_spec (register char *spec) { @@ -409,6 +409,6 @@ scan_printf_spec (register char *spec) return spec; default: - return 0; + return NULL; } } diff --git a/Src/diffutils/src/io.c b/Src/diffutils/src/io.c index 51159f2da..75a95607d 100644 --- a/Src/diffutils/src/io.c +++ b/Src/diffutils/src/io.c @@ -280,7 +280,7 @@ find_and_hash_each_line (struct file_data *current) char const HUGE *bufend = current->buffer + current->buffered_chars; char const HUGE *incomplete_tail = current->missing_newline && ROBUST_OUTPUT_STYLE (output_style) - ? bufend : (char const HUGE *) 0; + ? bufend : (char const HUGE *) NULL; int varies = length_varies; /* prepare_text_end put a zero word at the end of the buffer, @@ -992,17 +992,17 @@ read_files (struct file_data filevec[], int pretend_binary, int *bin_file) int skip_test = always_text_flag | pretend_binary; int appears_binary = 0; - if (bin_file) + if (bin_file != NULL) *bin_file = 0; appears_binary = pretend_binary | sip (&filevec[0], skip_test); - if (bin_file && appears_binary) + if (bin_file!=NULL && appears_binary) { *bin_file = 1; } if (filevec[0].desc != filevec[1].desc) { - if (bin_file) + if (bin_file!=NULL) { appears_binary = pretend_binary | sip (&filevec[1], skip_test); if (appears_binary) diff --git a/Src/diffutils/src/util.c b/Src/diffutils/src/util.c index a97bc4804..d7001df24 100644 --- a/Src/diffutils/src/util.c +++ b/Src/diffutils/src/util.c @@ -109,7 +109,7 @@ message5 (char const *format, char const *arg1, char const *arg2, char const *ar new->arg2 = concat (arg2, "", ""); new->arg3 = arg3 ? concat (arg3, "", "") : 0; new->arg4 = arg4 ? concat (arg4, "", "") : 0; - new->next = 0; + new->next = NULL; *msg_chain_end = new; msg_chain_end = &new->next; } @@ -149,7 +149,7 @@ setup_output (char const *name0, char const *name1, int depth) current_name0 = name0; current_name1 = name1; current_depth = depth; - outfile = 0; + outfile = NULL; } static pid_t pr_pid; @@ -159,7 +159,7 @@ begin_output () { char *name; - if (outfile != 0) + if (outfile != NULL) return; char *mySwitch = (switch_string != NULL ? switch_string : ""); @@ -253,7 +253,7 @@ begin_output () void finish_output () { - if (outfile != 0 && outfile != stdout) + if (outfile != NULL && outfile != stdout) { #if defined(__MSDOS__) || defined(__NT__) || defined(WIN32) if (pclose (outfile)) @@ -281,7 +281,7 @@ finish_output () #endif /*__MSDOS__||__NT__*/ } - outfile = 0; + outfile = NULL; } @@ -478,7 +478,7 @@ line_cmp (char const *s1, size_t len1, char const *s2, size_t len2) } } - return (1); + return 1; } /* Find the consecutive changes at the start of the script START. @@ -525,7 +525,7 @@ print_script (struct change *script, /* Disconnect them from the rest of the changes, making them a hunk, and remember the rest for next iteration. */ next = end->link; - end->link = 0; + end->link = NULL; #ifdef DEBUG debug_script (this); #endif @@ -547,13 +547,13 @@ print_1_line (char const *line_flag, char const * const *line) { char const HUGE *text = line[0], HUGE *limit = line[1]; /* Help the compiler. */ FILE *out = outfile; /* Help the compiler some more. */ - char const *flag_format = 0; + char const *flag_format = NULL; /* If -T was specified, use a Tab between the line-flag and the text. Otherwise use a Space (as Unix diff does). Print neither space nor tab if line-flags are empty. */ - if (line_flag && *line_flag) + if (line_flag != NULL && *line_flag != 0) { flag_format = tab_align_flag ? "%s\t" : "%s "; fprintf (out, flag_format, line_flag); @@ -561,7 +561,7 @@ print_1_line (char const *line_flag, char const * const *line) output_1_line (text, limit, flag_format, line_flag); - if ((!line_flag || line_flag[0]) && limit[-1] != '\n' && limit[-1] != '\r' + if ((line_flag == NULL || line_flag[0]) && limit[-1] != '\n' && limit[-1] != '\r' && line_end_char == '\n') fprintf (out, "\n\\ No newline at end of file\n"); } @@ -788,7 +788,7 @@ analyze_hunk (struct change *hunk, int *first0, int *last0, int *first1, int *la trivial = 0; } } - while ((next = next->link) != 0); + while ((next = next->link) != NULL); *last0 = l0; *last1 = l1; @@ -880,7 +880,7 @@ void debug_script (struct change *sp) { fflush (stdout); - for (; sp; sp = sp->link) + for (; sp!=NULL; sp = sp->link) fprintf (stderr, "%3d %3d delete %d insert %d\n", sp->line0, sp->line1, sp->deleted, sp->inserted); fflush (stderr); @@ -897,6 +897,6 @@ memchr (s, c, n) for (; p < lim; p++) if (*p == c) return (char *) p; - return 0; + return NULL; } #endif diff --git a/Src/files.h b/Src/files.h index a8b4518cb..355ee4f57 100644 --- a/Src/files.h +++ b/Src/files.h @@ -77,7 +77,7 @@ public: // bit manipulations static void SetMain(DWORD & flr, DWORD newmain) { flr = flr & ~FRESULT_MAIN_MASK; flr = flr | newmain; } static DWORD Main(DWORD flr) { return flr & FRESULT_MAIN_MASK; } - static bool IsModifier(DWORD flr, DWORD modifier) { return !!(flr & modifier); } + static bool IsModifier(DWORD flr, DWORD modifier) { return (flr & modifier) != 0; } /** @brief Return values for functions. */ enum FILES_RESULT diff --git a/Src/markdown.cpp b/Src/markdown.cpp index c3b0cee00..84dd8290b 100644 --- a/Src/markdown.cpp +++ b/Src/markdown.cpp @@ -776,7 +776,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags) { } } - if (pImage == NULL) + if (pImage == nullptr) { cbImage = 0; } @@ -789,7 +789,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags) // big endian: swab first cbImage &= ~1UL; pCopy = new unsigned char[cbImage]; - if (pCopy) + if (pCopy != nullptr) { for (size_t i = 0; i < cbImage / 2; ++i) *((uint16_t *)pCopy + i) = Poco::ByteOrder::flipBytes(*((uint16_t *)pImage + i)); @@ -797,7 +797,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags) delete m_pSharedMemory; pImage = pCopy; - if (pImage) + if (pImage != nullptr) { case 2 + 0: case 2 + 0 + 8: @@ -811,7 +811,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags) } cbImage = ucr::Utf8len_of_string(pchImage, cchImage); pCopy = new unsigned char[cbImage]; - if (pCopy) + if (pCopy != nullptr) { uint16_t *pu16; unsigned char *pu8; @@ -819,7 +819,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags) pu8 += ucr::Ucs4_to_Utf8(*pu16, pu8); } delete m_pSharedMemory; - m_pSharedMemory = NULL; + m_pSharedMemory = nullptr; pImage = pCopy; } break; @@ -838,7 +838,7 @@ CMarkdown::FileImage::FileImage(const TCHAR *path, size_t trunc, unsigned flags) delete m_pSharedMemory; m_pSharedMemory = NULL; pImage = pCopy; - if (pImage) + if (pImage != nullptr) { case 4 + 0: case 4 + 0 + 8: diff --git a/Src/paths.cpp b/Src/paths.cpp index 436782a2c..11eb762d4 100644 --- a/Src/paths.cpp +++ b/Src/paths.cpp @@ -253,10 +253,10 @@ String GetLongPath(const String& szPath, bool bExpandEnvs) // indicated by ^ ^ ^ if (_tcslen(ptr) > 2) end = _tcschr(pFullPath+2, _T('\\')); - if (end && !_tcsncmp(pFullPath, _T("\\\\"),2)) + if (end != nullptr && !_tcsncmp(pFullPath, _T("\\\\"),2)) end = _tcschr(end+1, _T('\\')); - if (!end) + if (end == nullptr) return pFullPath; *end = 0; @@ -264,20 +264,20 @@ String GetLongPath(const String& szPath, bool bExpandEnvs) ptr = &end[1]; // now walk down each directory and do short to long name conversion - while (ptr) + while (ptr != nullptr) { end = _tcschr(ptr, '\\'); // zero-terminate current component // (if we're at end, its already zero-terminated) - if (end) + if (end != nullptr) *end = 0; String sTemp(sLong); sTemp += '\\'; sTemp += ptr; - // advance to next component (or set ptr==0 to flag end) - ptr = (end ? end+1 : 0); + // advance to next component (or set ptr=`nullptr` to flag end) + ptr = (end!=nullptr ? end+1 : nullptr); // (Couldn't get info for just the directory from CFindFile) WIN32_FIND_DATA ffd; @@ -285,7 +285,7 @@ String GetLongPath(const String& szPath, bool bExpandEnvs) if (h == INVALID_HANDLE_VALUE) { sLong = sTemp; - if (ptr) + if (ptr != nullptr) { sLong += '\\'; sLong += ptr; @@ -335,16 +335,16 @@ bool CreateIfNeeded(const String& szPath) // Now fullPath holds our desired path TCHAR *ptr = fullPath; - TCHAR *end = NULL; + TCHAR *end = nullptr; // Skip to \ position d:\abcd or \\host\share\abcd // indicated by ^ ^ ^ if (_tcslen(ptr) > 2) end = _tcschr(fullPath+2, _T('\\')); - if (end && !_tcsncmp(fullPath, _T("\\\\"),2)) + if (end != nullptr && !_tcsncmp(fullPath, _T("\\\\"),2)) end = _tcschr(end+1, _T('\\')); - if (!end) return false; + if (end == nullptr) return false; // check that first component exists *end = 0; @@ -354,16 +354,16 @@ bool CreateIfNeeded(const String& szPath) ptr = end+1; - while (ptr) + while (ptr != nullptr) { end = _tcschr(ptr, '\\'); // zero-terminate current component // (if we're at end, its already zero-terminated) - if (end) + if (end != nullptr) *end = 0; - // advance to next component (or set ptr==0 to flag end) - ptr = (end ? end+1 : 0); + // advance to next component (or set ptr=`nullptr` to flag end) + ptr = (end != nullptr ? end+1 : nullptr); String sNextName; if (!GetDirName(fullPath, sNextName)) @@ -376,7 +376,7 @@ bool CreateIfNeeded(const String& szPath) } } // if not finished, restore directory string we're working in - if (ptr) + if (ptr != nullptr) *end = '\\'; } return true; diff --git a/Testing/GoogleTest/Plugins/Plugins_test.cpp b/Testing/GoogleTest/Plugins/Plugins_test.cpp index 7c539cf7b..c13e46f91 100644 --- a/Testing/GoogleTest/Plugins/Plugins_test.cpp +++ b/Testing/GoogleTest/Plugins/Plugins_test.cpp @@ -51,8 +51,8 @@ namespace String oldModulePath = env::GetProgPath(); env::SetProgPath(_T("c:/Program Files/WinMerge")); CAssureScriptsForThread asft; - PackingInfo *iu = NULL; - PrediffingInfo *ip = NULL; + PackingInfo *iu = nullptr; + PrediffingInfo *ip = nullptr; PluginManager pm; IPluginInfos *ppi = ± ppi->FetchPluginInfos(_T("../../Data/Office/excel.xls|../../Data/Office/excel.xls"), &iu, &ip); -- 2.11.0