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/PassRefPtr.h> 25#include <wtf/RefCounted.h> 26#include <wtf/Forward.h> 27#include <wtf/Vector.h> 28 29#if PLATFORM(IOS) 30#include "NativeImagePtr.h" 31#include <CoreGraphics/CoreGraphics.h> 32#include <wtf/RetainPtr.h> 33#elif PLATFORM(MAC) 34#include <wtf/RetainPtr.h> 35OBJC_CLASS NSImage; 36#elif PLATFORM(WIN) 37typedef struct HICON__* HICON; 38#elif PLATFORM(GTK) 39typedef struct _GdkPixbuf GdkPixbuf; 40#endif 41 42namespace WebCore { 43 44class GraphicsContext; 45class IntRect; 46 47class Icon : public RefCounted<Icon> { 48public: 49 static PassRefPtr<Icon> createIconForFiles(const Vector<String>& filenames); 50 51 ~Icon(); 52 53 void paint(GraphicsContext*, const IntRect&); 54 55#if PLATFORM(WIN) 56 static PassRefPtr<Icon> create(HICON hIcon) { return adoptRef(new Icon(hIcon)); } 57#endif 58 59#if PLATFORM(IOS) 60 // FIXME: Make this work for non-iOS ports and remove the PLATFORM(IOS)-guard. 61 static PassRefPtr<Icon> createIconForImage(NativeImagePtr); 62#endif 63 64private: 65#if PLATFORM(IOS) 66 Icon(CGImageRef); 67 RetainPtr<CGImageRef> m_cgImage; 68#elif PLATFORM(MAC) 69 Icon(NSImage*); 70 RetainPtr<NSImage> m_nsImage; 71#elif PLATFORM(WIN) 72 Icon(HICON); 73 HICON m_hIcon; 74#elif PLATFORM(GTK) 75 Icon(); 76 GdkPixbuf* m_icon; 77#elif PLATFORM(EFL) 78 Icon(); 79 Evas_Object* m_icon; 80#endif 81}; 82 83} 84 85#endif 86