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: hopefully final Created July 23, 2014, 4:28 p.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 /*
53 * Without namespace declaration, the identifier "Rectangle" is ambiguous
54 * See http://msdn.microsoft.com/en-us/library/windows/desktop/dd162898(v=vs.85) .aspx
55 */
56 namespace AdblockPlus
Felix Dahlke 2014/07/24 07:24:17 This would normally be an anonymous namespace, so
57 {
58 /**
59 * Replacement for ATL type CRect.
60 */
61 class Rectangle
62 : public RECT
63 {
64 public:
65 int Height() const
66 {
67 return bottom - top;
68 }
69
70 int Width() const
71 {
72 return right - left;
73 }
74 };
75 }
52 76
53 CPluginClass::CPluginClass() 77 CPluginClass::CPluginClass()
54 { 78 {
55 //Use this line to debug memory leaks 79 //Use this line to debug memory leaks
56 // _CrtDumpMemoryLeaks(); 80 // _CrtDumpMemoryLeaks();
57 81
58 m_isAdviced = false; 82 m_isAdviced = false;
59 m_nConnectionID = 0; 83 m_nConnectionID = 0;
60 m_hTabWnd = NULL; 84 m_hTabWnd = NULL;
61 m_hStatusBarWnd = NULL; 85 m_hStatusBarWnd = NULL;
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); 961 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
938 } 962 }
939 963
940 if (!hWndStatusBar) 964 if (!hWndStatusBar)
941 { 965 {
942 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar") 966 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar")
943 return true; 967 return true;
944 } 968 }
945 969
946 // Calculate pane height 970 // Calculate pane height
947 CRect rcStatusBar; 971 AdblockPlus::Rectangle rcStatusBar;
948 ::GetClientRect(hWndStatusBar, &rcStatusBar); 972 ::GetClientRect(hWndStatusBar, &rcStatusBar);
949 973
950 if (rcStatusBar.Height() > 0) 974 if (rcStatusBar.Height() > 0)
951 { 975 {
952 #ifdef _DEBUG 976 #ifdef _DEBUG
953 m_nPaneWidth = 70; 977 m_nPaneWidth = 70;
954 #else 978 #else
955 m_nPaneWidth = min(rcStatusBar.Height(), 22); 979 m_nPaneWidth = min(rcStatusBar.Height(), 22);
956 #endif 980 #endif
957 } 981 }
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts+1)); 1592 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts+1));
1569 LPINT lpParts = (LPINT)LocalLock(hLocal); 1593 LPINT lpParts = (LPINT)LocalLock(hLocal);
1570 memcpy(lpParts, (void*)lParam, wParam*sizeof(int)); 1594 memcpy(lpParts, (void*)lParam, wParam*sizeof(int));
1571 1595
1572 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++) 1596 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++)
1573 { 1597 {
1574 lpParts[i] -= pClass->m_nPaneWidth; 1598 lpParts[i] -= pClass->m_nPaneWidth;
1575 } 1599 }
1576 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts); 1600 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts);
1577 1601
1578 CRect rcPane; 1602 AdblockPlus::Rectangle rcPane;
1579 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane); 1603 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane);
1580 1604
1581 CRect rcClient; 1605 AdblockPlus::Rectangle rcClient;
1582 ::GetClientRect(hWnd, &rcClient); 1606 ::GetClientRect(hWnd, &rcClient);
1583 1607
1584 ::MoveWindow( 1608 ::MoveWindow(
1585 pClass->m_hPaneWnd, 1609 pClass->m_hPaneWnd,
1586 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth, 1610 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth,
1587 0, 1611 0,
1588 pClass->m_nPaneWidth, 1612 pClass->m_nPaneWidth,
1589 rcClient.Height(), 1613 rcClient.Height(),
1590 TRUE); 1614 TRUE);
1591 1615
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 case WM_SETCURSOR: 1682 case WM_SETCURSOR:
1659 { 1683 {
1660 ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); 1684 ::SetCursor(::LoadCursor(NULL, IDC_ARROW));
1661 return TRUE; 1685 return TRUE;
1662 } 1686 }
1663 case WM_PAINT: 1687 case WM_PAINT:
1664 { 1688 {
1665 PAINTSTRUCT ps; 1689 PAINTSTRUCT ps;
1666 HDC hDC = ::BeginPaint(hWnd, &ps); 1690 HDC hDC = ::BeginPaint(hWnd, &ps);
1667 1691
1668 CRect rcClient; 1692 AdblockPlus::Rectangle rcClient;
1669 ::GetClientRect(hWnd, &rcClient); 1693 ::GetClientRect(hWnd, &rcClient);
1670 1694
1671 int nDrawEdge = 0; 1695 int nDrawEdge = 0;
1672 1696
1673 // Old Windows background drawing 1697 // Old Windows background drawing
1674 if (pClass->m_hTheme == NULL) 1698 if (pClass->m_hTheme == NULL)
1675 { 1699 {
1676 ::FillRect(hDC, &rcClient, (HBRUSH)(COLOR_BTNFACE + 1)); 1700 ::FillRect(hDC, &rcClient, (HBRUSH)(COLOR_BTNFACE + 1));
1677 ::DrawEdge(hDC, &rcClient, BDR_RAISEDINNER, BF_LEFT); 1701 ::DrawEdge(hDC, &rcClient, BDR_RAISEDINNER, BF_LEFT);
1678 1702
1679 nDrawEdge = 3; 1703 nDrawEdge = 3;
1680 rcClient.left += 3; 1704 rcClient.left += 3;
1681 1705
1682 ::DrawEdge(hDC, &rcClient, BDR_SUNKENOUTER, BF_RECT); 1706 ::DrawEdge(hDC, &rcClient, BDR_SUNKENOUTER, BF_RECT);
1683 } 1707 }
1684 // Themed background drawing 1708 // Themed background drawing
1685 else 1709 else
1686 { 1710 {
1687 // Draw background 1711 // Draw background
1688 if (pfnDrawThemeBackground) 1712 if (pfnDrawThemeBackground)
1689 { 1713 {
1690 CRect rc = rcClient; 1714 AdblockPlus::Rectangle rc = rcClient;
1691 rc.right -= 2; 1715 rc.right -= 2;
1692 pfnDrawThemeBackground(pClass->m_hTheme, hDC, 0, 0, &rc, NULL); 1716 pfnDrawThemeBackground(pClass->m_hTheme, hDC, 0, 0, &rc, NULL);
1693 } 1717 }
1694 1718
1695 // Copy separator picture to left side 1719 // Copy separator picture to left side
1696 int nHeight = rcClient.Height(); 1720 int nHeight = rcClient.Height();
1697 int nWidth = rcClient.Width() - 2; 1721 int nWidth = rcClient.Width() - 2;
1698 1722
1699 for (int i = 0; i < 2; i++) 1723 for (int i = 0; i < 2; i++)
1700 { 1724 {
(...skipping 19 matching lines...) Expand all
1720 if (hIcon) 1744 if (hIcon)
1721 { 1745 {
1722 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL); 1746 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL);
1723 offx += 22; 1747 offx += 22;
1724 } 1748 }
1725 #ifdef _DEBUG 1749 #ifdef _DEBUG
1726 // Display version 1750 // Display version
1727 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0); 1751 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0);
1728 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont); 1752 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont);
1729 1753
1730 CRect rcText = rcClient; 1754 AdblockPlus::Rectangle rcText = rcClient;
1731 rcText.left += offx; 1755 rcText.left += offx;
1732 ::SetBkMode(hDC, TRANSPARENT); 1756 ::SetBkMode(hDC, TRANSPARENT);
1733 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER); 1757 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER);
1734 1758
1735 ::SelectObject(hDC, hOldFont); 1759 ::SelectObject(hDC, hOldFont);
1736 #endif // _DEBUG 1760 #endif // _DEBUG
1737 } 1761 }
1738 1762
1739 // Done! 1763 // Done!
1740 EndPaint(hWnd, &ps); 1764 EndPaint(hWnd, &ps);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 } 1994 }
1971 } 1995 }
1972 } 1996 }
1973 1997
1974 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1998 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1975 } 1999 }
1976 2000
1977 return hTabWnd; 2001 return hTabWnd;
1978 2002
1979 } 2003 }
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