1 #ifndef YICON_H 2 #define YICON_H 3 4 class YIcon: public refcounted { 5 public: 6 YIcon(upath fileName); 7 YIcon(ref<YImage> small, ref<YImage> large, ref<YImage> huge); 8 ~YIcon(); 9 10 ref<YImage> huge(); 11 ref<YImage> large(); 12 ref<YImage> small(); 13 14 ref<YImage> getScaledIcon(unsigned size); 15 iconName()16 upath iconName() const { return fPath; } 17 18 static class IResourceLocator* iconResourceLocator; 19 static ref<YIcon> getIcon(const char *name); 20 static void freeIcons(); isCached()21 bool isCached() { return fCached; } setCached(bool cached)22 void setCached(bool cached) { fCached = cached; } 23 24 static unsigned menuSize(); 25 static unsigned smallSize(); 26 static unsigned largeSize(); 27 static unsigned hugeSize(); 28 29 bool draw(Graphics &g, int x, int y, int size); 30 upath findIcon(unsigned size); 31 32 #ifdef SUPPORT_XDG_ICON_TYPE_CATEGORIES 33 enum /* class... or better not, simplify! */ TypeFilter { 34 NONE = 0, 35 /** Suitable for programs */ 36 FOR_APPS = 1, 37 /** Suitable for menu folders */ 38 FOR_MENUCATS = 2, 39 FOR_PLACES = 4, 40 FOR_DEVICES = 8, 41 42 FOR_ANY_PURPOSE = FOR_APPS | FOR_DEVICES | FOR_MENUCATS | FOR_APPS, 43 ALL = FOR_ANY_PURPOSE // | FROM_ANY_SOURCE 44 }; 45 #endif 46 47 private: 48 ref<YImage> fSmall; 49 ref<YImage> fLarge; 50 ref<YImage> fHuge; 51 52 bool loadedS; 53 bool loadedL; 54 bool loadedH; 55 bool fCached; 56 57 upath fPath; 58 59 void removeFromCache(); 60 static int cacheFind(upath name); 61 ref<YImage> loadIcon(unsigned size); 62 }; 63 64 #endif 65 66 // vim: set sw=4 ts=4 et: 67