1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_widget_IconLoaderHelperWin_h
7 #define mozilla_widget_IconLoaderHelperWin_h
9 #include "mozilla/widget/IconLoader.h"
10 #include "nsISupports.h"
12 namespace mozilla::widget
{
15 * Classes that want to hear about when icons load should subclass
16 * IconLoaderListenerWin, and implement the OnComplete() method,
17 * which will be called once the load of the icon has completed.
19 class IconLoaderListenerWin
: public nsISupports
{
21 IconLoaderListenerWin() = default;
23 // IconLoaderListenerWin needs to implement nsISupports in order for its
24 // subclasses to participate in cycle collection.
26 virtual nsresult
OnComplete() = 0;
29 virtual ~IconLoaderListenerWin() = default;
33 * This is a Helper used with mozilla::widget::IconLoader that implements the
34 * Windows-specific functionality for converting a loaded icon into an HICON.
36 class IconLoaderHelperWin final
: public mozilla::widget::IconLoader::Helper
{
38 explicit IconLoaderHelperWin(
39 mozilla::widget::IconLoaderListenerWin
* aLoadListener
);
41 // IconLoaderHelperWin needs to implement nsISupports in order for its
42 // subclasses to participate in cycle collection.
43 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
44 NS_DECL_CYCLE_COLLECTION_CLASS(IconLoaderHelperWin
)
46 nsresult
OnComplete(imgIContainer
* aImage
, const nsIntRect
& aRect
) override
;
49 * IconLoaderHelperWin will default the HICON returned by GetNativeIconImage
50 * to the application icon. Once the load of the icon by IconLoader has
51 * completed, GetNativeIconImage will return the loaded icon.
53 * Note that IconLoaderHelperWin owns this HICON. If you don't need it to hold
54 * onto the HICON anymore, call Destroy on it to deallocate. The
55 * IconLoaderHelperWin destructor will also deallocate the HICON if necessary.
57 HICON
GetNativeIconImage();
61 ~IconLoaderHelperWin();
64 RefPtr
<mozilla::widget::IconLoaderListenerWin
> mLoadListener
;
65 HICON mNativeIconImage
;
68 } // namespace mozilla::widget
70 #endif // mozilla_widget_IconLoaderHelperWin_h