| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | |
| 4 * | |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | |
| 6 * it under the terms of the GNU General Public License version 3 as | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU General Public License | |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | |
| 16 */ | |
| 17 | |
| 1 #include <cassert> | 18 #include <cassert> |
| 2 #include "NotificationWindow.h" | 19 #include "NotificationWindow.h" |
| 3 #include "../shared/Utils.h" | 20 #include "../shared/Utils.h" |
| 4 #include <algorithm> | 21 #include <algorithm> |
| 5 #include <fstream> | 22 #include <fstream> |
| 6 #include "../shared/MsHTMLUtils.h" | 23 #include "../shared/MsHTMLUtils.h" |
| 7 | 24 |
| 8 // it is taken from src/plugin/Resource.h | 25 // it is taken from src/plugin/Resource.h |
| 9 #define IDI_ICON_ENABLED 301 | 26 #define IDI_ICON_ENABLED 301 |
| 10 | 27 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 assert(linkIDCounter == m_links.size() && "The amount of links in the text is different from the amount of provided links"); | 135 assert(linkIDCounter == m_links.size() && "The amount of links in the text is different from the amount of provided links"); |
| 119 m_htmlPage = ReplaceMulti(m_htmlPage, L"<!--Title-->", ToUtf16String(notificat ion.GetTitle())); | 136 m_htmlPage = ReplaceMulti(m_htmlPage, L"<!--Title-->", ToUtf16String(notificat ion.GetTitle())); |
| 120 m_htmlPage = ReplaceMulti(m_htmlPage, L"<!--Body-->", body); | 137 m_htmlPage = ReplaceMulti(m_htmlPage, L"<!--Body-->", body); |
| 121 } | 138 } |
| 122 | 139 |
| 123 NotificationWindow::~NotificationWindow() | 140 NotificationWindow::~NotificationWindow() |
| 124 { | 141 { |
| 125 } | 142 } |
| 126 | 143 |
| 127 LRESULT NotificationWindow::OnCreate(const CREATESTRUCT* /*createStruct*/) { | 144 LRESULT NotificationWindow::OnCreate(const CREATESTRUCT* /*createStruct*/) { |
| 145 { | |
| 146 DCHandle hdc(GetDC()); | |
| 147 m_dpi = hdc.GetDeviceCaps(LOGPIXELSX); | |
| 148 } | |
| 128 m_bgColor.CreateSolidBrush(RGB(255, 255, 255)); | 149 m_bgColor.CreateSolidBrush(RGB(255, 255, 255)); |
| 129 | 150 |
| 130 CRect iconRect(CPoint(0, 0), CSize(kIconSize + 2 * kIconPadding, kIconSize + 2 * kIconPadding)); | 151 CRect iconRect(CPoint(0, 0), CSize(kIconSize + 2 * kIconPadding, kIconSize + 2 * kIconPadding)); |
| 131 m_icon.Create(m_hWnd, DPIAware(iconRect), nullptr, WS_CHILD | WS_VISIBLE | SS_ BITMAP | SS_CENTERIMAGE); | 152 m_icon.Create(m_hWnd, DPIAware(iconRect), nullptr, WS_CHILD | WS_VISIBLE | SS_ BITMAP | SS_CENTERIMAGE); |
| 132 LoadABPIcon(); | 153 LoadABPIcon(); |
| 133 | 154 |
| 134 m_axIE.Create(m_hWnd, DPIAware(CRect(CPoint(iconRect.right, 0), CSize(kWindowW idth - iconRect.right, kWindowHeight))), | 155 m_axIE.Create(m_hWnd, DPIAware(CRect(CPoint(iconRect.right, 0), CSize(kWindowW idth - iconRect.right, kWindowHeight))), |
| 135 L"", WS_CHILD | WS_VISIBLE, 0, kHTMLDocumentCtrlID); | 156 L"", WS_CHILD | WS_VISIBLE, 0, kHTMLDocumentCtrlID); |
| 136 m_axIE.CreateControl((L"mshtml:" + m_htmlPage).c_str()); | 157 m_axIE.CreateControl((L"mshtml:" + m_htmlPage).c_str()); |
| 137 ATL::CComPtr<IAxWinAmbientDispatch> axWinAmbient; | 158 ATL::CComPtr<IAxWinAmbientDispatch> axWinAmbient; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 ::DrawIconEx(tmpDC, 0, 0, hIcon, tmpRect.Width(), tmpRect.Height(), 0, nullptr , DI_NORMAL); | 294 ::DrawIconEx(tmpDC, 0, 0, hIcon, tmpRect.Width(), tmpRect.Height(), 0, nullptr , DI_NORMAL); |
| 274 m_iconImg.Attach(bitmap.Detach()); | 295 m_iconImg.Attach(bitmap.Detach()); |
| 275 tmpDC.SelectBitmap(prevBitmap); | 296 tmpDC.SelectBitmap(prevBitmap); |
| 276 m_icon.SetBitmap(m_iconImg); | 297 m_icon.SetBitmap(m_iconImg); |
| 277 } | 298 } |
| 278 | 299 |
| 279 POINT NotificationBorderWindow::GetWindowCoordinates() { | 300 POINT NotificationBorderWindow::GetWindowCoordinates() { |
| 280 HMONITOR primaryMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTOPRIMARY); | 301 HMONITOR primaryMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTOPRIMARY); |
| 281 { | 302 { |
| 282 DCHandle hdc(GetDC()); | 303 DCHandle hdc(GetDC()); |
| 283 m_dpi = hdc.GetDeviceCaps(LOGPIXELSX); | 304 m_dpi = hdc.GetDeviceCaps(LOGPIXELSX); |
|
Oleksandr
2015/08/18 11:47:40
Is this still needed, seeing that we now get dpi i
sergei
2015/08/18 11:58:40
It's a little bit odd. `GetWindowCoordinates` is a
| |
| 284 } | 305 } |
| 285 MONITORINFO monitorInfo = {}; | 306 MONITORINFO monitorInfo = {}; |
| 286 monitorInfo.cbSize = sizeof(monitorInfo); | 307 monitorInfo.cbSize = sizeof(monitorInfo); |
| 287 GetMonitorInfo(primaryMonitor, &monitorInfo); | 308 GetMonitorInfo(primaryMonitor, &monitorInfo); |
| 288 int windowX = monitorInfo.rcWork.right - DPIAware(kWindowWidth + kWindowMargin Right); | 309 int windowX = monitorInfo.rcWork.right - DPIAware(kWindowWidth + kWindowMargin Right); |
| 289 int windowY = monitorInfo.rcWork.bottom - DPIAware(kWindowHeight + kWindowMarg inBottom); | 310 int windowY = monitorInfo.rcWork.bottom - DPIAware(kWindowHeight + kWindowMarg inBottom); |
| 290 POINT coords = {windowX, windowY}; | 311 POINT coords = {windowX, windowY}; |
| 291 return coords; | 312 return coords; |
| 292 } | 313 } |
| 293 | 314 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 { | 362 { |
| 342 DestroyWindow(); | 363 DestroyWindow(); |
| 343 return 0; | 364 return 0; |
| 344 } | 365 } |
| 345 | 366 |
| 346 void NotificationBorderWindow::OnFinalMessage(HWND) { | 367 void NotificationBorderWindow::OnFinalMessage(HWND) { |
| 347 if (!!m_onDestroyedCallback) { | 368 if (!!m_onDestroyedCallback) { |
| 348 m_onDestroyedCallback(); | 369 m_onDestroyedCallback(); |
| 349 } | 370 } |
| 350 } | 371 } |
| LEFT | RIGHT |