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
|
#ifndef _AUTOBITMAP_H
#define _AUTOBITMAP_H
#include "bitmap.h"
#include <api/syscb/callbacks/syscb.h>
#include <api/syscb/callbacks/skincb.h>
#include <tataki/export.h>
#ifdef DROP_BITMAP_ON_IDLE
#include <api/timer/timerclient.h>
#define DROP_BITMAP_ANCESTOR , public TimerClientDI
#else
#define DROP_BITMAP_ANCESTOR
#endif
class TATAKIAPI AutoSkinBitmap : public SysCallback DROP_BITMAP_ANCESTOR {
public:
AutoSkinBitmap(const wchar_t *_name=NULL);
virtual ~AutoSkinBitmap();
const wchar_t *setBitmap(const wchar_t *_name=NULL);
int setBitmap(int _id=0);
// call this when you get freeResources called on you
// doesn't hurt to call as much as you want
void reset();
void reload() { getBitmap(); } // force a reload
// this loads the bitmap if necessary
SkinBitmap *getBitmap();
operator SkinBitmap *() { return getBitmap(); }
const wchar_t *operator =(const wchar_t *_name) { return setBitmap(_name); }
int operator =(int _id) { return setBitmap(_id); }
const wchar_t *getBitmapName();
void setHInstanceBitmapColorGroup(const wchar_t *_colorgroup);
enum
{
RESAMPLING_MODE_NONE = 0,
RESAMPLING_MODE_SUPERSAMPLING = 1,
};
void setResamplingMode(int mode);
int getResamplingMode();
// feel free to add more methods here to help make using this class
// transparent...
int getWidth() { return getBitmap()->getWidth(); };
int getHeight() { return getBitmap()->getHeight(); };
void stretchToRectAlpha(ifc_canvas *canvas, RECT *r, int alpha=255) {
getBitmap()->stretchToRectAlpha(canvas, r, alpha);
}
void stretchToRectAlpha(ifc_canvas *canvas, RECT *r, RECT *dest, int alpha=255) {
getBitmap()->stretchToRectAlpha(canvas, r, dest, alpha);
}
void stretchToRect(ifc_canvas *canvas, RECT *r) {
getBitmap()->stretchToRect(canvas, r);
}
void blitAlpha(ifc_canvas *canvas, int x, int y, int alpha=255) {
getBitmap()->blitAlpha(canvas, x, y, alpha);
}
#ifdef _WIN32
void setHInstance(HINSTANCE hinstance); // use this if you use autoskinbitmap and resource in a wac
#endif
#ifdef DROP_BITMAP_ON_IDLE
virtual void timerclient_timerCallback(int id);
#endif
protected:
FOURCC getEventType() { return SysCallback::SKINCB; }
int notify(int msg, intptr_t param1 = 0, intptr_t param2 = 0)
{
if (msg == SkinCallback::RESET)
return skincb_onReset();
else
return 0;
}
int skincb_onReset();
#ifdef DROP_BITMAP_ON_IDLE
virtual void tryUnload();
#endif
private:
int use;
int id;
wchar_t *name;
wchar_t *colorgroup;
SkinBitmap *bitmap;
int resamplingMode;
#ifdef _WIN32
HINSTANCE myInstance;
#endif
#ifdef DROP_BITMAP_ON_IDLE
uint32_t lastuse;
#endif
protected:
RECVS_DISPATCH;
};
#endif
|