From 120694551ba58b62b2d0e7c68021e7525cdeac0e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 18 Aug 2020 11:48:46 +0300 Subject: code cleaning --- plugins/SmileyAdd/src/AniSmileyObject.cpp | 1 - plugins/SmileyAdd/src/anim.cpp | 7 ++- plugins/SmileyAdd/src/anim.h | 28 ++++------ plugins/SmileyAdd/src/customsmiley.h | 5 -- plugins/SmileyAdd/src/imagecache.h | 15 +----- plugins/SmileyAdd/src/options.cpp | 8 +-- plugins/SmileyAdd/src/services.cpp | 2 +- plugins/SmileyAdd/src/services.h | 7 ++- plugins/SmileyAdd/src/smileyroutines.cpp | 4 +- plugins/SmileyAdd/src/smileys.cpp | 1 - plugins/SmileyAdd/src/smileys.h | 22 ++------ plugins/SmileyAdd/src/smltool.cpp | 86 +++++++++++-------------------- 12 files changed, 60 insertions(+), 126 deletions(-) (limited to 'plugins') diff --git a/plugins/SmileyAdd/src/AniSmileyObject.cpp b/plugins/SmileyAdd/src/AniSmileyObject.cpp index 78bf8dba2b..b5043d51c1 100644 --- a/plugins/SmileyAdd/src/AniSmileyObject.cpp +++ b/plugins/SmileyAdd/src/AniSmileyObject.cpp @@ -22,7 +22,6 @@ class CAniSmileyObject; class CAniSmileyObject : public ISmileyBase, public MZeroedObject { -private: typedef enum { animStdOle, animDrctRichEd, animHpp } AnimType; POINTL m_rectOrig; diff --git a/plugins/SmileyAdd/src/anim.cpp b/plugins/SmileyAdd/src/anim.cpp index 59ed0135ad..c55ce8c6d4 100644 --- a/plugins/SmileyAdd/src/anim.cpp +++ b/plugins/SmileyAdd/src/anim.cpp @@ -20,10 +20,9 @@ along with this program. If not, see . Animate::Animate(SmileyType *sml, RECT &rect, HDC hdcMem, HBRUSH hbr, bool clip) : m_sml(sml), - m_img(nullptr), - m_nFramePosition(0), m_sel(false), m_clip(clip), - m_offset(0), m_running(false), - m_hdcMem(hdcMem), m_hbr(hbr) + m_clip(clip), + m_hdcMem(hdcMem), + m_hbr(hbr) { m_cliprect = rect; } diff --git a/plugins/SmileyAdd/src/anim.h b/plugins/SmileyAdd/src/anim.h index 553f8dc695..e2af7932de 100644 --- a/plugins/SmileyAdd/src/anim.h +++ b/plugins/SmileyAdd/src/anim.h @@ -21,27 +21,23 @@ along with this program. If not, see . class Animate { -private: - - ImageBase *m_img; + ImageBase *m_img = nullptr; SmileyType *m_sml; HDC m_hdcMem; HBRUSH m_hbr; + RECT m_cliprect; - RECT m_cliprect; - - unsigned m_nFramePosition; - int m_offset; + int m_nFramePosition = 0; + int m_offset = 0; int m_counter = 0; - bool m_running; - bool m_sel; + bool m_running = false; + bool m_sel = false; bool m_clip; void DrawFrame(HDC hdc); public: - Animate(SmileyType *sml, RECT &rect, HDC hdcMem, HBRUSH hbr, bool clip); ~Animate(); @@ -56,16 +52,14 @@ public: class AnimatedPack { -private: OBJLIST m_AniList; - HWND m_hwnd; - int m_wsize; - - HBRUSH m_hbr; + HWND m_hwnd; + int m_wsize; + HBRUSH m_hbr; HBITMAP m_hBmp; - HDC m_hdcMem; - HBITMAP m_hOld; + HDC m_hdcMem; + HBITMAP m_hOld; public: AnimatedPack(HWND hwnd, int wsize, SIZE &sel, COLORREF bkg); diff --git a/plugins/SmileyAdd/src/customsmiley.h b/plugins/SmileyAdd/src/customsmiley.h index 2deb75102c..65cd87b7cb 100644 --- a/plugins/SmileyAdd/src/customsmiley.h +++ b/plugins/SmileyAdd/src/customsmiley.h @@ -29,11 +29,9 @@ public: class SmileyPackCType { -public: typedef SMOBJLIST SmileyVectorType; typedef SMOBJLIST SmileyLookupType; -private: SmileyVectorType m_SmileyList; SmileyLookupType m_SmileyLookup; @@ -62,10 +60,7 @@ public: class SmileyPackCListType { -public: typedef SMOBJLIST SmileyPackVectorType; - -private: SmileyPackVectorType m_SmileyPacks; public: diff --git a/plugins/SmileyAdd/src/imagecache.h b/plugins/SmileyAdd/src/imagecache.h index 275257efba..49e19ca330 100644 --- a/plugins/SmileyAdd/src/imagecache.h +++ b/plugins/SmileyAdd/src/imagecache.h @@ -50,19 +50,15 @@ public: static int CompareImg(const ImageBase *p1, const ImageBase *p2); }; - -typedef enum +enum IcoTypeEnum { icoDll, icoFile, icoIcl -} -IcoTypeEnum; - +}; class IconType : public ImageBase { -private: HICON m_SmileyIcon; public: @@ -74,10 +70,8 @@ public: void GetSize(SIZE &size); }; - class ImageListItemType : public ImageBase { -private: int m_index; HIMAGELIST m_hImList; @@ -92,7 +86,6 @@ public: class ImageType : public ImageBase { -private: int m_nCurrentFrame; int m_nFrameCount; @@ -100,7 +93,6 @@ private: Gdiplus::PropertyItem* m_pPropertyItem; public: - ImageType(const unsigned id, const CMStringW &file, IStream *pStream); ImageType(const unsigned id, const CMStringW &file, const int index, const IcoTypeEnum type); ~ImageType(); @@ -117,11 +109,9 @@ public: class ImageFType : public ImageBase { -protected: HBITMAP m_bmp; public: - ImageFType(const unsigned id); ImageFType(const unsigned id, const CMStringW &file); ~ImageFType(); @@ -136,4 +126,3 @@ ImageBase* AddCacheImage(const CMStringW &file, int index); void DestroyImageCache(void); #endif - diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp index 9e592bc72c..a086486a00 100644 --- a/plugins/SmileyAdd/src/options.cpp +++ b/plugins/SmileyAdd/src/options.cpp @@ -178,7 +178,7 @@ class COptionsDialog : public CDlgBase tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_STATE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tvi.item.stateMask = TVIS_STATEIMAGEMASK | TVIS_SELECTED; - SmileyCategoryListType::SmileyCategoryVectorType &smc = *tmpsmcat.GetSmileyCategoryList(); + auto &smc = *tmpsmcat.GetSmileyCategoryList(); for (int i = 0; i < smc.getCount(); i++) { if (smc[i].IsVisible()) { tvi.item.pszText = (wchar_t *)smc[i].GetDisplayName().c_str(); @@ -224,7 +224,7 @@ class COptionsDialog : public CDlgBase bool useOne = !chkStdPack.GetState(); bool usePhysProto = chkUsePhys.GetState(); - SmileyCategoryListType::SmileyCategoryVectorType &smc = *tmpsmcat.GetSmileyCategoryList(); + auto &smc = *tmpsmcat.GetSmileyCategoryList(); for (auto &it : smc) { bool visiblecat = usePhysProto ? !it->IsAcc() : !it->IsPhysProto(); bool visible = useOne ? !it->IsProto() : visiblecat; @@ -333,7 +333,7 @@ public: tmpsmcat = g_SmileyCategories; - SmileyCategoryListType::SmileyCategoryVectorType &smc = *g_SmileyCategories.GetSmileyCategoryList(); + auto &smc = *g_SmileyCategories.GetSmileyCategoryList(); for (auto &it : smc) { HICON hIcon = nullptr; if (it->IsProto()) { @@ -389,7 +389,7 @@ public: // Cleanup database CMStringW empty; - SmileyCategoryListType::SmileyCategoryVectorType &smc = *g_SmileyCategories.GetSmileyCategoryList(); + auto &smc = *g_SmileyCategories.GetSmileyCategoryList(); for (auto &it : smc) if (tmpsmcat.GetSmileyCategory(it->GetName()) == nullptr) opt.WritePackFileName(empty, it->GetName()); diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index 4dbfc85775..aca7e2a8c5 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -221,7 +221,7 @@ INT_PTR CustomCatMenu(WPARAM hContact, LPARAM lParam) int RebuildContactMenu(WPARAM wParam, LPARAM) { - SmileyCategoryListType::SmileyCategoryVectorType &smc = *g_SmileyCategories.GetSmileyCategoryList(); + auto &smc = *g_SmileyCategories.GetSmileyCategoryList(); char *protnam = Proto_GetBaseAccountName(wParam); bool haveMenu = IsSmileyProto(protnam); diff --git a/plugins/SmileyAdd/src/services.h b/plugins/SmileyAdd/src/services.h index 70cad9b45f..86b1b3742b 100644 --- a/plugins/SmileyAdd/src/services.h +++ b/plugins/SmileyAdd/src/services.h @@ -22,19 +22,18 @@ along with this program. If not, see . // service commands INT_PTR ReplaceSmileysCommand(WPARAM wParam, LPARAM lParam); -INT_PTR GetSmileyIconCommand(WPARAM wParam, LPARAM lParam); INT_PTR ShowSmileySelectionCommand(WPARAM wParam, LPARAM lParam); INT_PTR GetInfoCommand(WPARAM wParam, LPARAM); INT_PTR GetInfoCommand2(WPARAM wParam, LPARAM); -INT_PTR ParseText(WPARAM wParam, LPARAM lParam); -INT_PTR ParseTextW(WPARAM wParam, LPARAM lParam); INT_PTR RegisterPack(WPARAM wParam, LPARAM lParam); INT_PTR ParseTextBatch(WPARAM wParam, LPARAM lParam); INT_PTR FreeTextBatch(WPARAM wParam, LPARAM lParam); INT_PTR CustomCatMenu(WPARAM, LPARAM lParam); -int RebuildContactMenu(WPARAM wParam, LPARAM); INT_PTR ReloadPack(WPARAM, LPARAM lParam); INT_PTR LoadContactSmileys(WPARAM, LPARAM lParam); + +// events +int RebuildContactMenu(WPARAM wParam, LPARAM); int AccountListChanged(WPARAM wParam, LPARAM lParam); int DbSettingChanged(WPARAM wParam, LPARAM lParam); int ReloadColour(WPARAM, LPARAM); diff --git a/plugins/SmileyAdd/src/smileyroutines.cpp b/plugins/SmileyAdd/src/smileyroutines.cpp index 0968fe10f3..b3b5137712 100644 --- a/plugins/SmileyAdd/src/smileyroutines.cpp +++ b/plugins/SmileyAdd/src/smileyroutines.cpp @@ -34,8 +34,8 @@ void LookupAllSmileys(SmileyPackType *smileyPack, SmileyPackCType *smileyCPack, { if (lpstrText == nullptr || *lpstrText == 0) return; - SmileyPackType::SmileyLookupType *sml = smileyPack ? smileyPack->GetSmileyLookup() : nullptr; - SmileyPackCType::SmileyLookupType *smlc = smileyCPack ? &smileyCPack->GetSmileyLookup() : nullptr; + auto *sml = smileyPack ? smileyPack->GetSmileyLookup() : nullptr; + auto *smlc = smileyCPack ? &smileyCPack->GetSmileyLookup() : nullptr; // Precompute number of smileys int smlszo = sml ? sml->getCount() : 0; diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index 702b6e72a6..12137c6657 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -668,7 +668,6 @@ SmileyCategoryType::SmileyCategoryType(SmileyPackListType *pSPS, const CMStringW opt.ReadPackFileName(m_Filename, m_Name, defaultFilename); } - void SmileyCategoryType::Load(void) { bool bVisibleCat = opt.UsePhysProto ? !IsAcc() : !IsPhysProto(); diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h index bf7accdc8c..8071e12770 100644 --- a/plugins/SmileyAdd/src/smileys.h +++ b/plugins/SmileyAdd/src/smileys.h @@ -125,9 +125,7 @@ template struct SMOBJLIST : public OBJLIST class SmileyLookup { -private: MRegexp16 m_pattern; - int m_ind; CMStringW m_text; bool m_valid; @@ -137,7 +135,6 @@ public: { size_t pos, len; SmileyLocType(size_t p, size_t l) : pos(p), len(l) {} - SmileyLocType() {} }; typedef SMOBJLIST SmileyLocVecType; @@ -150,16 +147,8 @@ public: bool IsValid(void) const { return m_valid; } }; - class SmileyPackType { -public: - typedef SMOBJLIST SmileyVectorType; - typedef SMOBJLIST SmileyLookupType; - - POINT selec, win; - -private: CMStringW m_Filename; //used as identification CMStringW m_Name; CMStringW m_Author; @@ -171,7 +160,10 @@ private: int m_VisibleCount; + typedef SMOBJLIST SmileyVectorType; SmileyVectorType m_SmileyList; + + typedef SMOBJLIST SmileyLookupType; SmileyLookupType m_SmileyLookup; bool errorFound; @@ -183,6 +175,8 @@ public: SmileyPackType(); ~SmileyPackType(); + POINT selec, win; + SmileyVectorType& GetSmileyList(void) { return m_SmileyList; } SmileyLookupType* GetSmileyLookup(void) { return &m_SmileyLookup; } @@ -210,10 +204,7 @@ public: class SmileyPackListType { -public: typedef SMOBJLIST SmileyPackVectorType; - -private: SmileyPackVectorType m_SmileyPacks; public: @@ -240,7 +231,6 @@ typedef enum class SmileyCategoryType { -private: CMStringW m_Name; CMStringW m_DisplayName; CMStringW m_Filename; //functions as identification @@ -285,10 +275,8 @@ public: class SmileyCategoryListType { -public: typedef SMOBJLIST SmileyCategoryVectorType; -private: SmileyCategoryVectorType m_SmileyCategories; SmileyPackListType *m_pSmileyPackStore; diff --git a/plugins/SmileyAdd/src/smltool.cpp b/plugins/SmileyAdd/src/smltool.cpp index 648fa473f6..901cb07210 100644 --- a/plugins/SmileyAdd/src/smltool.cpp +++ b/plugins/SmileyAdd/src/smltool.cpp @@ -21,18 +21,17 @@ along with this program. If not, see . #define SB_MYMOVE 20 -// +///////////////////////////////////////////////////////////////////////////////////////// // SmileyToolwindowType -// + class SmileyToolWindowType { -private: - unsigned m_NumberOfVerticalButtons; - unsigned m_NumberOfHorizontalButtons; - SIZE m_BitmapWidth; - SIZE m_ButtonSize; - unsigned m_ButtonSpace; - unsigned m_NumberOfButtons; + unsigned m_NumberOfVerticalButtons = 0; + unsigned m_NumberOfHorizontalButtons = 0; + SIZE m_BitmapWidth = { 0, 0 }; + SIZE m_ButtonSize = { 0, 0 }; + unsigned m_ButtonSpace = -1; + unsigned m_NumberOfButtons = 0; int m_WindowSizeY; HWND m_hwndDialog; @@ -46,10 +45,10 @@ private: int m_Direction; UINT m_TargetMessage; WPARAM m_TargetWParam; - int rowSel; + int rowSel = -1; bool m_Choosing; - AnimatedPack *m_AniPack; + AnimatedPack *m_AniPack = nullptr; void InitDialog(LPARAM lParam); void PaintWindow(void); @@ -71,8 +70,7 @@ public: LRESULT DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam); }; - -LRESULT CALLBACK DlgProcSmileyToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK DlgProcSmileyToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { SmileyToolWindowType *pOD = (SmileyToolWindowType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); if (pOD == nullptr) { @@ -90,24 +88,11 @@ LRESULT CALLBACK DlgProcSmileyToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, return Result; } - -SmileyToolWindowType::SmileyToolWindowType(HWND hWnd) +SmileyToolWindowType::SmileyToolWindowType(HWND hWnd) : + m_hwndDialog(hWnd) { - m_hwndDialog = hWnd; - rowSel = -1; - m_AniPack = nullptr; - - m_NumberOfVerticalButtons = 0; - m_NumberOfHorizontalButtons = 0; - m_BitmapWidth.cx = 0; - m_BitmapWidth.cy = 0; - m_ButtonSize.cx = 0; - m_ButtonSize.cy = 0; - m_ButtonSpace = 1; - m_NumberOfButtons = 0; } - LRESULT SmileyToolWindowType::DialogProcedure(UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT Result = FALSE; @@ -229,7 +214,6 @@ void SmileyToolWindowType::SmileySel(int but) } } - void SmileyToolWindowType::ScrollV(int action, int dist) { SCROLLINFO si; @@ -297,7 +281,6 @@ void SmileyToolWindowType::ScrollV(int action, int dist) } } - void SmileyToolWindowType::MouseMove(int xposition, int yposition) { if (m_CurrentHotTrack == -2) return; //prevent focussing when not drawn yet! @@ -312,23 +295,21 @@ void SmileyToolWindowType::MouseMove(int xposition, int yposition) int but = CalculateCoordinatesToButton(pt, si.nPos); if (but<0) SendMessage(m_hToolTip, TTM_ACTIVATE, FALSE, 0); - else - if (m_CurrMouseTrack != but) { - TOOLINFO ti = { 0 }; - ti.cbSize = sizeof(ti); - ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; - ti.hwnd = m_hwndDialog; - ti.uId = (UINT_PTR)m_hwndDialog; - const CMStringW &toolText = m_pSmileyPack->GetSmiley(but)->GetToolText(); - ti.lpszText = const_cast(toolText.c_str()); - SendMessage(m_hToolTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); - SendMessage(m_hToolTip, TTM_ACTIVATE, TRUE, 0); - } + else if (m_CurrMouseTrack != but) { + TOOLINFO ti = { 0 }; + ti.cbSize = sizeof(ti); + ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + ti.hwnd = m_hwndDialog; + ti.uId = (UINT_PTR)m_hwndDialog; + const CMStringW &toolText = m_pSmileyPack->GetSmiley(but)->GetToolText(); + ti.lpszText = const_cast(toolText.c_str()); + SendMessage(m_hToolTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); + SendMessage(m_hToolTip, TTM_ACTIVATE, TRUE, 0); + } + m_CurrMouseTrack = but; } - - void SmileyToolWindowType::KeyUp(WPARAM wParam, LPARAM lParam) { int colSel = -1, numKey = -1; @@ -432,7 +413,6 @@ void SmileyToolWindowType::KeyUp(WPARAM wParam, LPARAM lParam) InsertSmiley(); } - void SmileyToolWindowType::InitDialog(LPARAM lParam) { LPCREATESTRUCT createStruct = (LPCREATESTRUCT)lParam; @@ -532,7 +512,6 @@ void SmileyToolWindowType::InitDialog(LPARAM lParam) SendMessage(m_hToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); } - void SmileyToolWindowType::PaintWindow(void) { SCROLLINFO si; @@ -565,12 +544,11 @@ void SmileyToolWindowType::PaintWindow(void) EndPaint(m_hwndDialog, &ps); } - void SmileyToolWindowType::CreateSmileyWinDim(void) { m_NumberOfButtons = m_pSmileyPack->VisibleSmileyCount(); - - if (m_NumberOfButtons == 0) return; + if (m_NumberOfButtons == 0) + return; // Find largest smiley if (m_pSmileyPack->selec.x == 0 || m_pSmileyPack->selec.y == 0) { @@ -581,7 +559,7 @@ void SmileyToolWindowType::CreateSmileyWinDim(void) else { m_ButtonSize.cx = 0; m_ButtonSize.cy = 0; - SmileyPackType::SmileyVectorType &sml = m_pSmileyPack->GetSmileyList(); + auto &sml = m_pSmileyPack->GetSmileyList(); for (unsigned i = 0; i < m_NumberOfButtons; i++) { SIZE smsz; sml[i].GetSize(smsz); @@ -591,9 +569,7 @@ void SmileyToolWindowType::CreateSmileyWinDim(void) } } } - else { - m_ButtonSize = *(SIZE*)&m_pSmileyPack->selec; - } + else m_ButtonSize = *(SIZE*)&m_pSmileyPack->selec; if (m_pSmileyPack->win.x == 0 || m_pSmileyPack->win.y == 0) { if (opt.IEViewStyle) { @@ -634,7 +610,6 @@ void SmileyToolWindowType::CreateSmileyWinDim(void) m_WindowSizeY = wndsz - (wndsz % colsz) + m_ButtonSpace; } - void SmileyToolWindowType::CreateSmileyBitmap(HDC hdc) { const RECT rc = { 0, 0, m_BitmapWidth.cx, m_WindowSizeY }; @@ -667,7 +642,6 @@ void SmileyToolWindowType::CreateSmileyBitmap(HDC hdc) } } - RECT SmileyToolWindowType::CalculateButtonToCoordinates(int buttonPosition, int scroll) { int row, rowpos; @@ -686,11 +660,9 @@ RECT SmileyToolWindowType::CalculateButtonToCoordinates(int buttonPosition, int pt.top = (row - scroll) * (m_ButtonSize.cy + m_ButtonSpace) + m_ButtonSpace; pt.right = pt.left + m_ButtonSize.cx; pt.bottom = pt.top + m_ButtonSize.cy; - return pt; } - int SmileyToolWindowType::CalculateCoordinatesToButton(POINT pt, int scroll) { const int rowpos = (pt.x - m_ButtonSpace) / (m_ButtonSize.cx + m_ButtonSpace); -- cgit v1.2.3