Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginClass.cpp

Issue 6215938672164864: [IE] Replace ATL::CRect (Closed)
Patch Set: Comments addressed; Rebased Created July 23, 2014, 11:59 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include "PluginClass.h" 3 #include "PluginClass.h"
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #include "PluginSystem.h" 5 #include "PluginSystem.h"
6 #ifdef SUPPORT_FILTER 6 #ifdef SUPPORT_FILTER
7 #include "PluginFilter.h" 7 #include "PluginFilter.h"
8 #endif 8 #endif
9 #include "PluginMimeFilterClient.h" 9 #include "PluginMimeFilterClient.h"
10 #include "PluginClient.h" 10 #include "PluginClient.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; 42 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal;
43 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser; 43 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser;
44 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; 44 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow;
45 45
46 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; 46 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2;
47 47
48 #ifdef SUPPORT_WHITELIST 48 #ifdef SUPPORT_WHITELIST
49 std::map<UINT,CString> CPluginClass::s_menuDomains; 49 std::map<UINT,CString> CPluginClass::s_menuDomains;
50 #endif 50 #endif
51 51
52 namespace
53 {
54 // Without an extra namespace within the anonymous one, the identifier "Rectan gle" is ambiguous
55 // See http://msdn.microsoft.com/en-us/library/windows/desktop/dd162898(v=vs.8 5).aspx
56 namespace AdblockPlus
57 {
58 /**
59 * Replacement for ATL type CRect.
60 */
61 class Rectangle
62 : public RECT
63 {
64 public:
65 // C++11 noexcept
66 int Height() const
67 {
68 return bottom - top;
69 }
70
71 // C++11 noexcept
72 int Width() const
73 {
74 return right - left;
75 }
76 };
77 }
78 }
52 79
53 CPluginClass::CPluginClass() 80 CPluginClass::CPluginClass()
54 { 81 {
55 //Use this line to debug memory leaks 82 //Use this line to debug memory leaks
56 // _CrtDumpMemoryLeaks(); 83 // _CrtDumpMemoryLeaks();
57 84
58 m_isAdviced = false; 85 m_isAdviced = false;
59 m_nConnectionID = 0; 86 m_nConnectionID = 0;
60 m_hTabWnd = NULL; 87 m_hTabWnd = NULL;
61 m_hStatusBarWnd = NULL; 88 m_hStatusBarWnd = NULL;
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); 964 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
938 } 965 }
939 966
940 if (!hWndStatusBar) 967 if (!hWndStatusBar)
941 { 968 {
942 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar") 969 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar")
943 return true; 970 return true;
944 } 971 }
945 972
946 // Calculate pane height 973 // Calculate pane height
947 CRect rcStatusBar; 974 AdblockPlus::Rectangle rcStatusBar;
948 ::GetClientRect(hWndStatusBar, &rcStatusBar); 975 ::GetClientRect(hWndStatusBar, &rcStatusBar);
949 976
950 if (rcStatusBar.Height() > 0) 977 if (rcStatusBar.Height() > 0)
951 { 978 {
952 #ifdef _DEBUG 979 #ifdef _DEBUG
953 m_nPaneWidth = 70; 980 m_nPaneWidth = 70;
954 #else 981 #else
955 m_nPaneWidth = min(rcStatusBar.Height(), 22); 982 m_nPaneWidth = min(rcStatusBar.Height(), 22);
956 #endif 983 #endif
957 } 984 }
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts+1)); 1595 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts+1));
1569 LPINT lpParts = (LPINT)LocalLock(hLocal); 1596 LPINT lpParts = (LPINT)LocalLock(hLocal);
1570 memcpy(lpParts, (void*)lParam, wParam*sizeof(int)); 1597 memcpy(lpParts, (void*)lParam, wParam*sizeof(int));
1571 1598
1572 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++) 1599 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++)
1573 { 1600 {
1574 lpParts[i] -= pClass->m_nPaneWidth; 1601 lpParts[i] -= pClass->m_nPaneWidth;
1575 } 1602 }
1576 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts); 1603 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts);
1577 1604
1578 CRect rcPane; 1605 AdblockPlus::Rectangle rcPane;
1579 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane); 1606 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane);
1580 1607
1581 CRect rcClient; 1608 AdblockPlus::Rectangle rcClient;
1582 ::GetClientRect(hWnd, &rcClient); 1609 ::GetClientRect(hWnd, &rcClient);
1583 1610
1584 ::MoveWindow( 1611 ::MoveWindow(
1585 pClass->m_hPaneWnd, 1612 pClass->m_hPaneWnd,
1586 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth, 1613 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth,
1587 0, 1614 0,
1588 pClass->m_nPaneWidth, 1615 pClass->m_nPaneWidth,
1589 rcClient.Height(), 1616 rcClient.Height(),
1590 TRUE); 1617 TRUE);
1591 1618
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 case WM_SETCURSOR: 1685 case WM_SETCURSOR:
1659 { 1686 {
1660 ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); 1687 ::SetCursor(::LoadCursor(NULL, IDC_ARROW));
1661 return TRUE; 1688 return TRUE;
1662 } 1689 }
1663 case WM_PAINT: 1690 case WM_PAINT:
1664 { 1691 {
1665 PAINTSTRUCT ps; 1692 PAINTSTRUCT ps;
1666 HDC hDC = ::BeginPaint(hWnd, &ps); 1693 HDC hDC = ::BeginPaint(hWnd, &ps);
1667 1694
1668 CRect rcClient; 1695 AdblockPlus::Rectangle rcClient;
1669 ::GetClientRect(hWnd, &rcClient); 1696 ::GetClientRect(hWnd, &rcClient);
1670 1697
1671 int nDrawEdge = 0; 1698 int nDrawEdge = 0;
1672 1699
1673 // Old Windows background drawing 1700 // Old Windows background drawing
1674 if (pClass->m_hTheme == NULL) 1701 if (pClass->m_hTheme == NULL)
1675 { 1702 {
1676 ::FillRect(hDC, &rcClient, (HBRUSH)(COLOR_BTNFACE + 1)); 1703 ::FillRect(hDC, &rcClient, (HBRUSH)(COLOR_BTNFACE + 1));
1677 ::DrawEdge(hDC, &rcClient, BDR_RAISEDINNER, BF_LEFT); 1704 ::DrawEdge(hDC, &rcClient, BDR_RAISEDINNER, BF_LEFT);
1678 1705
1679 nDrawEdge = 3; 1706 nDrawEdge = 3;
1680 rcClient.left += 3; 1707 rcClient.left += 3;
1681 1708
1682 ::DrawEdge(hDC, &rcClient, BDR_SUNKENOUTER, BF_RECT); 1709 ::DrawEdge(hDC, &rcClient, BDR_SUNKENOUTER, BF_RECT);
1683 } 1710 }
1684 // Themed background drawing 1711 // Themed background drawing
1685 else 1712 else
1686 { 1713 {
1687 // Draw background 1714 // Draw background
1688 if (pfnDrawThemeBackground) 1715 if (pfnDrawThemeBackground)
1689 { 1716 {
1690 CRect rc = rcClient; 1717 AdblockPlus::Rectangle rc = rcClient;
1691 rc.right -= 2; 1718 rc.right -= 2;
1692 pfnDrawThemeBackground(pClass->m_hTheme, hDC, 0, 0, &rc, NULL); 1719 pfnDrawThemeBackground(pClass->m_hTheme, hDC, 0, 0, &rc, NULL);
1693 } 1720 }
1694 1721
1695 // Copy separator picture to left side 1722 // Copy separator picture to left side
1696 int nHeight = rcClient.Height(); 1723 int nHeight = rcClient.Height();
1697 int nWidth = rcClient.Width() - 2; 1724 int nWidth = rcClient.Width() - 2;
1698 1725
1699 for (int i = 0; i < 2; i++) 1726 for (int i = 0; i < 2; i++)
1700 { 1727 {
(...skipping 19 matching lines...) Expand all
1720 if (hIcon) 1747 if (hIcon)
1721 { 1748 {
1722 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL); 1749 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL);
1723 offx += 22; 1750 offx += 22;
1724 } 1751 }
1725 #ifdef _DEBUG 1752 #ifdef _DEBUG
1726 // Display version 1753 // Display version
1727 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0); 1754 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0);
1728 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont); 1755 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont);
1729 1756
1730 CRect rcText = rcClient; 1757 Local::Rectangle rcText = rcClient;
sergei 2014/07/23 13:34:49 Should Local be renamed to AdblockPlus?
Eric 2014/07/23 16:34:14 That's what I get for compiling in Release configu
1731 rcText.left += offx; 1758 rcText.left += offx;
1732 ::SetBkMode(hDC, TRANSPARENT); 1759 ::SetBkMode(hDC, TRANSPARENT);
1733 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER); 1760 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER);
1734 1761
1735 ::SelectObject(hDC, hOldFont); 1762 ::SelectObject(hDC, hOldFont);
1736 #endif // _DEBUG 1763 #endif // _DEBUG
1737 } 1764 }
1738 1765
1739 // Done! 1766 // Done!
1740 EndPaint(hWnd, &ps); 1767 EndPaint(hWnd, &ps);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 } 1997 }
1971 } 1998 }
1972 } 1999 }
1973 2000
1974 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 2001 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1975 } 2002 }
1976 2003
1977 return hTabWnd; 2004 return hTabWnd;
1978 2005
1979 } 2006 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld