1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
Miranda SmileyAdd Plugin
Copyright (C) 2008 - 2011 Boris Krasnovskiy
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SMILEYADD_IMAGECACHE_H_
#define SMILEYADD_IMAGECACHE_H_
class ImageBase
{
protected:
unsigned m_id;
long m_lRefCount;
time_t m_timestamp;
public:
ImageBase(unsigned id);
virtual ~ImageBase() {}
long AddRef(void);
long Release(void);
void ProcessTimerTick(time_t ts);
virtual void GetSize(SIZE&) {};
virtual int GetFrameCount(void) const { return 0; }
virtual int GetFrameDelay(void) const { return 0; }
virtual HICON GetIcon(void) { return nullptr; };
virtual void DrawInternal(HDC, int, int, int, int) {};
virtual void SelectFrame(int) {}
bool IsAnimated(void) const { return GetFrameCount() > 1; }
HBITMAP GetBitmap(COLORREF bkgClr, int sizeX, int sizeY);
void Draw(HDC dc, RECT &rc, bool clip);
int SelectNextFrame(const int frame);
static int CompareImg(const ImageBase *p1, const ImageBase *p2);
};
enum IcoTypeEnum
{
icoDll,
icoFile,
icoIcl
};
class IconType : public ImageBase
{
HICON m_SmileyIcon;
public:
IconType(const unsigned id, const CMStringW &file, const int index, const IcoTypeEnum type);
~IconType();
void DrawInternal(HDC dc, int x, int y, int sizeX, int sizeY);
HICON GetIcon(void);
void GetSize(SIZE &size);
};
class ImageListItemType : public ImageBase
{
int m_index;
HIMAGELIST m_hImList;
public:
ImageListItemType(const unsigned id, HIMAGELIST hImList, int index);
void DrawInternal(HDC dc, int x, int y, int sizeX, int sizeY);
HICON GetIcon(void);
void GetSize(SIZE &size);
};
class ImageType : public ImageBase
{
int m_nCurrentFrame;
int m_nFrameCount;
Gdiplus::Bitmap* m_bmp;
Gdiplus::PropertyItem* m_pPropertyItem;
public:
ImageType(const unsigned id, const CMStringW &file, IStream *pStream);
ImageType(const unsigned id, const CMStringW &file, const int index, const IcoTypeEnum type);
~ImageType();
void SelectFrame(int frame);
void DrawInternal(HDC dc, int x, int y, int sizeX, int sizeY);
HICON GetIcon(void);
void GetSize(SIZE &size);
int GetFrameDelay(void) const;
int GetFrameCount(void) const { return m_nFrameCount; }
};
class ImageFType : public ImageBase
{
HBITMAP m_bmp;
public:
ImageFType(const unsigned id);
ImageFType(const unsigned id, const CMStringW &file);
~ImageFType();
void DrawInternal(HDC dc, int x, int y, int sizeX, int sizeY);
HICON GetIcon(void);
void GetSize(SIZE &size);
};
ImageBase* AddCacheImage(const CMStringW &file, int index);
void DestroyImageCache(void);
#endif
|