| 1 | /* |
| 2 | * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library 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 GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public License |
| 15 | * along with this library; see the file COPYING.LIB. If not, write to |
| 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #ifndef Icon_h |
| 22 | #define Icon_h |
| 23 | |
| 24 | #include <wtf/Forward.h> |
| 25 | #include <wtf/RefCounted.h> |
| 26 | #include <wtf/RefPtr.h> |
| 27 | #include <wtf/RetainPtr.h> |
| 28 | |
| 29 | #if PLATFORM(IOS_FAMILY) |
| 30 | #include "NativeImage.h" |
| 31 | #include <CoreGraphics/CoreGraphics.h> |
| 32 | #elif PLATFORM(MAC) |
| 33 | OBJC_CLASS NSImage; |
| 34 | #elif PLATFORM(WIN) |
| 35 | typedef struct HICON__* HICON; |
| 36 | #elif PLATFORM(GTK) |
| 37 | typedef struct _GdkPixbuf GdkPixbuf; |
| 38 | #endif |
| 39 | |
| 40 | namespace WebCore { |
| 41 | |
| 42 | class GraphicsContext; |
| 43 | class FloatRect; |
| 44 | |
| 45 | class Icon : public RefCounted<Icon> { |
| 46 | public: |
| 47 | WEBCORE_EXPORT static RefPtr<Icon> createIconForFiles(const Vector<String>& filenames); |
| 48 | |
| 49 | WEBCORE_EXPORT ~Icon(); |
| 50 | |
| 51 | void paint(GraphicsContext&, const FloatRect&); |
| 52 | |
| 53 | #if PLATFORM(WIN) |
| 54 | static Ref<Icon> create(HICON hIcon) { return adoptRef(*new Icon(hIcon)); } |
| 55 | #endif |
| 56 | |
| 57 | #if PLATFORM(IOS_FAMILY) |
| 58 | // FIXME: Make this work for non-iOS ports and remove the PLATFORM(IOS_FAMILY)-guard. |
| 59 | WEBCORE_EXPORT static RefPtr<Icon> createIconForImage(const NativeImagePtr&); |
| 60 | #endif |
| 61 | |
| 62 | #if PLATFORM(MAC) |
| 63 | static RefPtr<Icon> createIconForUTI(const String&); |
| 64 | static RefPtr<Icon> createIconForFileExtension(const String&); |
| 65 | #endif |
| 66 | |
| 67 | private: |
| 68 | #if PLATFORM(IOS_FAMILY) |
| 69 | Icon(const RetainPtr<CGImageRef>&); |
| 70 | RetainPtr<CGImageRef> m_cgImage; |
| 71 | #elif PLATFORM(MAC) |
| 72 | Icon(NSImage*); |
| 73 | RetainPtr<NSImage> m_nsImage; |
| 74 | #elif PLATFORM(WIN) |
| 75 | Icon(HICON); |
| 76 | HICON m_hIcon; |
| 77 | #elif PLATFORM(GTK) |
| 78 | Icon(); |
| 79 | GdkPixbuf* m_icon; |
| 80 | #endif |
| 81 | }; |
| 82 | |
| 83 | } |
| 84 | |
| 85 | #endif |
| 86 | |