2010-05-07 04:47:10 -05:00
|
|
|
/*
|
2011-12-03 16:38:03 -06:00
|
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
2010-05-07 04:47:10 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2010-05-20 16:31:55 -05:00
|
|
|
#ifndef _IMAGE_CACHE_H
|
|
|
|
#define _IMAGE_CACHE_H
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <String.h>
|
2010-05-08 14:35:28 -05:00
|
|
|
|
|
|
|
#include <libsupport/KeyMap.h>
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
class BBitmap;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
class ImageCache {
|
|
|
|
public:
|
2021-06-13 17:34:30 -05:00
|
|
|
static ImageCache* Get();
|
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
/* Returns the image corresponding to the which constant */
|
2021-06-13 17:34:30 -05:00
|
|
|
BBitmap* GetImage(const char* keyName);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-06-13 17:34:30 -05:00
|
|
|
void AddImage(BString name, BBitmap* which);
|
|
|
|
void DeleteImage(BString name);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
/* Frees the singleton instance of the cache, must be
|
|
|
|
* called when the application quits.
|
2010-05-07 04:47:10 -05:00
|
|
|
*/
|
2010-05-20 16:31:55 -05:00
|
|
|
static void Release();
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
protected:
|
|
|
|
ImageCache();
|
|
|
|
~ImageCache();
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
private:
|
2021-06-13 17:34:30 -05:00
|
|
|
void _LoadResource(int identifier, const char* key);
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
static ImageCache* fInstance;
|
|
|
|
KeyMap<BString, BBitmap*> fBitmaps;
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
|
|
|
|
2021-06-13 17:34:30 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
#endif // _IMAGE_CACHE_H
|
2021-06-13 17:34:30 -05:00
|
|
|
|