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

Delta Between Two Patch Sets: src/engine/NotificationWindow.h

Issue 6505394822184960: Issue 1109 - Support notifications (Closed)
Left Patch Set: add border and shadow and remove title background Created July 3, 2015, 1:37 p.m.
Right Patch Set: fix obtaining of DPI value of content (NotificationWindow) of NotificationBorderWindow Created Aug. 18, 2015, 9:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 #pragma once 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
18 #ifndef NOTIFICATION_WINDOW_H
19 #define NOTIFICATION_WINDOW_H
20
2 #include <atlbase.h> 21 #include <atlbase.h>
3 #include <atlwin.h> 22 #include <atlwin.h>
4 #include <atlctl.h> 23 #include <atlctl.h>
5 #include <atlimage.h> 24 #include <atlimage.h>
6 #include <AdblockPlus/JsValue.h> 25 #include <AdblockPlus/JsValue.h>
7 #include <AdblockPlus/Notification.h> 26 #include <AdblockPlus/Notification.h>
8 #include <functional> 27 #include <functional>
9 #include <MsHtmdid.h> 28 #include <MsHtmdid.h>
10 29
11 class IconStaticControl : public ATL::CWindow 30 class IconStaticControl : public ATL::CWindow
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 96
78 operator bool() const 97 operator bool() const
79 { 98 {
80 return m_handle == nullptr; 99 return m_handle == nullptr;
81 } 100 }
82 protected: 101 protected:
83 T m_handle; 102 T m_handle;
84 private: 103 private:
85 ScopedObjectHandle(const ScopedObjectHandle&); 104 ScopedObjectHandle(const ScopedObjectHandle&);
86 ScopedObjectHandle& operator=(const ScopedObjectHandle&); 105 ScopedObjectHandle& operator=(const ScopedObjectHandle&);
87 };
88
89 class CFont : public ScopedObjectHandle<HFONT>
90 {
91 public:
92 explicit CFont(HFONT hFont = nullptr) : ScopedObjectHandle(hFont)
93 {
94 }
95
96 void CreateFontIndirect(const LOGFONT* logFontArg, uint32_t dpi)
97 {
98 ATLASSERT(m_handle == nullptr);
99 LOGFONT logFont = *logFontArg;
100 logFont.lfHeight = -MulDiv(dpi, logFont.lfHeight, 72);
Oleksandr 2015/07/22 09:45:36 I really don't see us going over the max int size
sergei 2015/07/23 14:17:58 We don't need CFont I forgot to remove it, I used
101 m_handle = ::CreateFontIndirect(&logFont);
102 }
103 }; 106 };
104 107
105 class CBrush : public ScopedObjectHandle<HBRUSH> 108 class CBrush : public ScopedObjectHandle<HBRUSH>
106 { 109 {
107 public: 110 public:
108 explicit CBrush(HBRUSH brush = nullptr) : ScopedObjectHandle(brush) 111 explicit CBrush(HBRUSH brush = nullptr) : ScopedObjectHandle(brush)
109 { 112 {
110 } 113 }
111 114
112 void CreateSolidBrush(COLORREF crColor) 115 void CreateSolidBrush(COLORREF crColor)
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 private: 289 private:
287 LRESULT OnCreate(const CREATESTRUCT* createStruct); 290 LRESULT OnCreate(const CREATESTRUCT* createStruct);
288 void OnSize(uint32_t wParam, CSize size); 291 void OnSize(uint32_t wParam, CSize size);
289 LRESULT OnClick(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& handled); 292 LRESULT OnClick(UINT msg, WPARAM wParam, LPARAM lParam, BOOL& handled);
290 293
291 void OnFinalMessage(HWND) override; 294 void OnFinalMessage(HWND) override;
292 295
293 // returns {windowX, windowY} of top left corner on the monitor 296 // returns {windowX, windowY} of top left corner on the monitor
294 POINT GetWindowCoordinates(); 297 POINT GetWindowCoordinates();
295 private: 298 private:
296 // m_content is used a holder of all children and we need it to have a border. 299 // m_content is used as a holder of all children and we need it to have a bord er.
Oleksandr 2015/07/22 09:45:36 NIT: "used AS a holder"
297 // It seems the most correct way to have a border to set WS_POPUPWINDOW style 300 // It seems the most correct way to have a border to set WS_POPUPWINDOW style
298 // and paint the border in WM_NCPAINT but it simply does not work here. 301 // and paint the border in WM_NCPAINT but it simply does not work here.
299 NotificationWindow m_content; 302 NotificationWindow m_content;
300 std::function<void()> m_onDestroyedCallback; 303 std::function<void()> m_onDestroyedCallback;
301 }; 304 };
305 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld