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: Created June 25, 2014, 7:02 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 | « src/plugin/ATL_Deprecate.h ('k') | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal; 45 CComAutoCriticalSection CPluginClass::s_criticalSectionLocal;
46 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser; 46 CComAutoCriticalSection CPluginClass::s_criticalSectionBrowser;
47 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow; 47 CComAutoCriticalSection CPluginClass::s_criticalSectionWindow;
48 48
49 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2; 49 CComQIPtr<IWebBrowser2> CPluginClass::s_asyncWebBrowser2;
50 50
51 #ifdef SUPPORT_WHITELIST 51 #ifdef SUPPORT_WHITELIST
52 std::map<UINT,std::wstring> CPluginClass::s_menuDomains; 52 std::map<UINT,std::wstring> CPluginClass::s_menuDomains;
53 #endif 53 #endif
54 54
55 //-------------------------------------------------------
56 // Rectangle
57 //-------------------------------------------------------
55 58
59 namespace {
Oleksandr 2014/07/09 19:29:08 Nit: New line before {
60 // Without an extra namespace within the anonymous one, the identifier "Rectan gle" is ambiguous
Felix Dahlke 2014/07/10 04:49:03 Hm, guess it conflicts with this one? http://msdn
Eric 2014/07/23 11:25:05 FYI. This URL is exhibited a defect in the code re
Eric 2014/07/23 12:03:18 Well, the base class is "RECT", and it doesn't see
61 namespace Local {
Oleksandr 2014/07/09 19:29:08 Nit: New line before {
62 /**
63 * Replacement for ATL type CRect.
64 */
65 class Rectangle
66 : public RECT
67 {
68 public:
69 // C++11 noexcept
Felix Dahlke 2014/07/10 04:49:03 I guess you're marking this so we can make it noex
Eric 2014/07/23 11:25:05 Yes.
70 inline int Height() const
Felix Dahlke 2014/07/10 04:49:03 inline is redundant here, since this will only be
71 {
72 return bottom - top;
73 }
74
75 // C++11 noexcept
76 inline int Width() const
77 {
78 return right - left;
79 }
80 };
81 }
82 }
83
84 //-------------------------------------------------------
85 // CPluginClass
Felix Dahlke 2014/07/10 04:49:03 We don't do class headers like this usually, I per
Oleksandr 2014/07/14 07:56:21 Visually I think it makes sense, and sometimes it'
86 //-------------------------------------------------------
56 CPluginClass::CPluginClass() 87 CPluginClass::CPluginClass()
57 { 88 {
58 //Use this line to debug memory leaks 89 //Use this line to debug memory leaks
59 // _CrtDumpMemoryLeaks(); 90 // _CrtDumpMemoryLeaks();
60 91
61 m_isAdviced = false; 92 m_isAdviced = false;
62 m_nConnectionID = 0; 93 m_nConnectionID = 0;
63 m_hTabWnd = NULL; 94 m_hTabWnd = NULL;
64 m_hStatusBarWnd = NULL; 95 m_hStatusBarWnd = NULL;
65 m_hPaneWnd = NULL; 96 m_hPaneWnd = NULL;
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT); 973 hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
943 } 974 }
944 975
945 if (!hWndStatusBar) 976 if (!hWndStatusBar)
946 { 977 {
947 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, L"Clas s::CreateStatusBarPane - No status bar") 978 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, L"Clas s::CreateStatusBarPane - No status bar")
948 return true; 979 return true;
949 } 980 }
950 981
951 // Calculate pane height 982 // Calculate pane height
952 CRect rcStatusBar; 983 Local::Rectangle rcStatusBar;
953 ::GetClientRect(hWndStatusBar, &rcStatusBar); 984 ::GetClientRect(hWndStatusBar, &rcStatusBar);
954 985
955 if (rcStatusBar.Height() > 0) 986 if (rcStatusBar.Height() > 0)
956 { 987 {
957 #ifdef _DEBUG 988 #ifdef _DEBUG
958 m_nPaneWidth = 70; 989 m_nPaneWidth = 70;
959 #else 990 #else
960 m_nPaneWidth = min(rcStatusBar.Height(), 22); 991 m_nPaneWidth = min(rcStatusBar.Height(), 22);
961 #endif 992 #endif
962 } 993 }
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts+1)); 1585 HLOCAL hLocal = LocalAlloc(LHND, sizeof(int) * (nParts+1));
1555 LPINT lpParts = (LPINT)LocalLock(hLocal); 1586 LPINT lpParts = (LPINT)LocalLock(hLocal);
1556 memcpy(lpParts, (void*)lParam, wParam*sizeof(int)); 1587 memcpy(lpParts, (void*)lParam, wParam*sizeof(int));
1557 1588
1558 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++) 1589 for (unsigned i = 0; i < STATUSBAR_PANE_NUMBER; i++)
1559 { 1590 {
1560 lpParts[i] -= pClass->m_nPaneWidth; 1591 lpParts[i] -= pClass->m_nPaneWidth;
1561 } 1592 }
1562 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts); 1593 LRESULT hRet = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPa ram, (LPARAM)lpParts);
1563 1594
1564 CRect rcPane; 1595 Local::Rectangle rcPane;
1565 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane); 1596 ::SendMessage(hWnd, SB_GETRECT, STATUSBAR_PANE_NUMBER, (LPARAM)&rcPane);
1566 1597
1567 CRect rcClient; 1598 Local::Rectangle rcClient;
1568 ::GetClientRect(hWnd, &rcClient); 1599 ::GetClientRect(hWnd, &rcClient);
1569 1600
1570 ::MoveWindow( 1601 ::MoveWindow(
1571 pClass->m_hPaneWnd, 1602 pClass->m_hPaneWnd,
1572 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth, 1603 lpParts[STATUSBAR_PANE_NUMBER] - pClass->m_nPaneWidth,
1573 0, 1604 0,
1574 pClass->m_nPaneWidth, 1605 pClass->m_nPaneWidth,
1575 rcClient.Height(), 1606 rcClient.Height(),
1576 TRUE); 1607 TRUE);
1577 1608
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 case WM_SETCURSOR: 1675 case WM_SETCURSOR:
1645 { 1676 {
1646 ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); 1677 ::SetCursor(::LoadCursor(NULL, IDC_ARROW));
1647 return TRUE; 1678 return TRUE;
1648 } 1679 }
1649 case WM_PAINT: 1680 case WM_PAINT:
1650 { 1681 {
1651 PAINTSTRUCT ps; 1682 PAINTSTRUCT ps;
1652 HDC hDC = ::BeginPaint(hWnd, &ps); 1683 HDC hDC = ::BeginPaint(hWnd, &ps);
1653 1684
1654 CRect rcClient; 1685 Local::Rectangle rcClient;
1655 ::GetClientRect(hWnd, &rcClient); 1686 ::GetClientRect(hWnd, &rcClient);
1656 1687
1657 int nDrawEdge = 0; 1688 int nDrawEdge = 0;
1658 1689
1659 // Old Windows background drawing 1690 // Old Windows background drawing
1660 if (pClass->m_hTheme == NULL) 1691 if (pClass->m_hTheme == NULL)
1661 { 1692 {
1662 ::FillRect(hDC, &rcClient, (HBRUSH)(COLOR_BTNFACE + 1)); 1693 ::FillRect(hDC, &rcClient, (HBRUSH)(COLOR_BTNFACE + 1));
1663 ::DrawEdge(hDC, &rcClient, BDR_RAISEDINNER, BF_LEFT); 1694 ::DrawEdge(hDC, &rcClient, BDR_RAISEDINNER, BF_LEFT);
1664 1695
1665 nDrawEdge = 3; 1696 nDrawEdge = 3;
1666 rcClient.left += 3; 1697 rcClient.left += 3;
1667 1698
1668 ::DrawEdge(hDC, &rcClient, BDR_SUNKENOUTER, BF_RECT); 1699 ::DrawEdge(hDC, &rcClient, BDR_SUNKENOUTER, BF_RECT);
1669 } 1700 }
1670 // Themed background drawing 1701 // Themed background drawing
1671 else 1702 else
1672 { 1703 {
1673 // Draw background 1704 // Draw background
1674 if (pfnDrawThemeBackground) 1705 if (pfnDrawThemeBackground)
1675 { 1706 {
1676 CRect rc = rcClient; 1707 Local::Rectangle rc = rcClient;
1677 rc.right -= 2; 1708 rc.right -= 2;
1678 pfnDrawThemeBackground(pClass->m_hTheme, hDC, 0, 0, &rc, NULL); 1709 pfnDrawThemeBackground(pClass->m_hTheme, hDC, 0, 0, &rc, NULL);
1679 } 1710 }
1680 1711
1681 // Copy separator picture to left side 1712 // Copy separator picture to left side
1682 int nHeight = rcClient.Height(); 1713 int nHeight = rcClient.Height();
1683 int nWidth = rcClient.Width() - 2; 1714 int nWidth = rcClient.Width() - 2;
1684 1715
1685 for (int i = 0; i < 2; i++) 1716 for (int i = 0; i < 2; i++)
1686 { 1717 {
(...skipping 19 matching lines...) Expand all
1706 if (hIcon) 1737 if (hIcon)
1707 { 1738 {
1708 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL); 1739 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL);
1709 offx += 22; 1740 offx += 22;
1710 } 1741 }
1711 #ifdef _DEBUG 1742 #ifdef _DEBUG
1712 // Display version 1743 // Display version
1713 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0); 1744 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0);
1714 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont); 1745 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont);
1715 1746
1716 CRect rcText = rcClient; 1747 Local::Rectangle rcText = rcClient;
1717 rcText.left += offx; 1748 rcText.left += offx;
1718 ::SetBkMode(hDC, TRANSPARENT); 1749 ::SetBkMode(hDC, TRANSPARENT);
1719 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER); 1750 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER);
1720 1751
1721 ::SelectObject(hDC, hOldFont); 1752 ::SelectObject(hDC, hOldFont);
1722 #endif // _DEBUG 1753 #endif // _DEBUG
1723 } 1754 }
1724 1755
1725 // Done! 1756 // Done!
1726 EndPaint(hWnd, &ps); 1757 EndPaint(hWnd, &ps);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 } 1987 }
1957 } 1988 }
1958 } 1989 }
1959 1990
1960 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1991 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1961 } 1992 }
1962 1993
1963 return hTabWnd; 1994 return hTabWnd;
1964 1995
1965 } 1996 }
OLDNEW
« no previous file with comments | « src/plugin/ATL_Deprecate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld