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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/*
Popup Plus plugin for Miranda IM
Copyright © 2002 Luca Santarelli,
© 2004-2007 Victor Pavlychko
© 2010 MPK
© 2010 Merlin_de
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; either version 2
of the License, or (at your option) any later version.
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __skin_h__
#define __skin_h__
#include <stdio.h>
#include <fstream>
class MyBitmap;
class PopupWnd2;
class PopupSkin
{
public:
enum
{
ST_TYPEMASK = 0x07,
ST_NOTHING = 0x00,
ST_ICON = 0x01,
ST_TEXT = 0x02,
ST_TITLE = 0x03,
ST_BITMAP = 0x04,
ST_MYBITMAP = 0x05,
ST_AVATAR = 0x06,
ST_CLOCK = 0x07,
ST_STRETCH = 0x08,
ST_MONO = 0x10,
ST_BLEND = 0x20,
ST_BADPOS = 0x40
};
enum
{
DF_STATIC = 0x01,
DF_ANIMATE = 0x02,
DF_ALL = 0xff
};
enum
{
// left, separator, digits, am/pm, right
CLOCK_LEFT = 0,
CLOCK_SEPARATOR = 1,
CLOCK_DIGITS = 2,
CLOCK_AM = 12,
CLOCK_PM = 13,
CLOCK_RIGHT = 14,
CLOCK_ITEMS = 1 + 1 + 10 + 2 + 1
};
struct SKINELEMENT
{
int type;
union
{
HICON hic;
HBITMAP hbm;
MyBitmap *myBmp;
HFONT hfn;
};
unsigned long flags;
unsigned long flag_mask;
Formula fx, fy, fw, fh;
int clocksize[CLOCK_ITEMS];
int clockstart[CLOCK_ITEMS];
int proportional;
COLORREF textColor;
SKINELEMENT *next;
};
struct RenderInfo
{
bool hasAvatar;
int titlew, textw;
int realtextw, texth;
int actw;
RECT textRect;
};
private:
LPTSTR m_name;
int m_bottom_gap, m_right_gap;
int m_legacy_region_opacity, m_shadow_region_opacity;
int m_popup_version;
bool m_internalClock;
Formula m_fw, m_fh;
SKINELEMENT *m_elements;
char *m_flag_names[32];
mutable unsigned long m_flags;
void loadOptions(std::wistream &f);
SKINELEMENT *loadObject(std::wistream &f);
void loadSkin(std::wistream &f);
void loadSkin(LPCTSTR fn);
void loadSkin(LPCTSTR lpName, LPCTSTR lpType);
void freeSkin(SKINELEMENT *head);
SIZE measureAction(HDC hdc, POPUPACTION *act) const;
SIZE measureActionBar(HDC hdc, PopupWnd2 *wnd) const;
void drawAction(MyBitmap *bmp, POPUPACTION *act, int x, int y, bool hover) const;
void drawActionBar(MyBitmap *bmp, PopupWnd2 *wnd, int x, int y) const;
public:
PopupSkin(LPCTSTR aName = nullptr);
~PopupSkin();
void measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options) const;
void display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, uint32_t drawFlags = DF_ALL) const;
bool onMouseMove(PopupWnd2 *wnd, int x, int y) const;
bool onMouseLeave(PopupWnd2 *wnd) const;
bool load(LPCTSTR dir); // load skin from current directory
SKINELEMENT *getSubSkin() { return m_elements; }
int getBottomGap() const { return m_bottom_gap; }
int getRightGap() const { return m_right_gap; }
int useInternalClock() const { return m_internalClock; }
int getLegacyRegionOpacity() const { return m_legacy_region_opacity; }
int getShadowRegionOpacity() const { return m_shadow_region_opacity; }
const LPTSTR getName() const { return m_name; }
const char *getFlagName(int id) const { return m_flag_names[id - 1]; }
bool getFlag(int id) const { return (m_flags & (1 << (id - 1))) != 0; }
void setFlag(int id, bool val) const
{
if (val)
m_flags |= 1 << (id - 1);
else
m_flags &= ~(1 << (id - 1));
}
void saveOpts() const;
void loadOpts() const;
};
class Skins
{
public:
struct SKINLIST
{
PopupSkin *skin;
LPTSTR dir;
LPTSTR name;
SKINLIST *next;
};
private:
SKINLIST *m_skins;
public:
Skins();
~Skins();
bool load();
const PopupSkin *getSkin(LPCTSTR name);
const SKINLIST *getSkinList() const { return m_skins; }
void loadActiveSkin();
void freeAllButActive();
};
extern Skins skins;
#endif
|