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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
/*
Miranda NG: the free IM client for Microsoft* Windows*
Copyright (c) 2012-18 Miranda NG team (https://miranda-ng.org),
Copyright (c) 2000-08 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
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 M_ske_H_INC
#define M_ske_H_INC
#include <m_clistint.h>
/*defaults*/
#define DEFAULT_FIT_MODE FM_STRETCH
#define DEFAULT_STYLE ST_BRUSH
#define DEFAULT_BKCOLOUR GetSysColor(COLOR_3DFACE)
#define DEFAULT_SELBKCOLOUR GetSysColor(COLOR_HIGHLIGHT)
#define SIZING_MARGIN 3
/* Fit mode */
#define FM_STRETCH 0
#define FM_TILE_HORZ 1
#define FM_TILE_VERT 2
#define FM_TILE_BOTH 3
/*Object types*/
#define OT_ANY 0
#define OT_GLYPHOBJECT 1
#define OT_FONTOBJECT 2
/*STYLE INDEXEX*/
#define ST_SKIP 0
#define ST_PARENT 1
#define ST_BRUSH 2
#define ST_IMAGE 3
#define ST_SOLARIZE 4 //Not used yet.
#define ST_FRAGMENT 5
#define ST_GRADIENT 6
//formats:
#define ADT_TOP 0x00000000
#define ADT_LEFT 0x00000000
#define ADT_HCENTER 0x00000001
#define ADT_RIGHT 0x00000002
#define ADT_VCENTER 0x00000004
#define ADT_BOTTOM 0x00000008
//#define ADT_ECLIPSE 64
/*SERVICES*/
//toggle the 'hide offline contacts' flag and call CLUI
#define MS_CLIST_TOGGLEHIDEOFFLINE "CList/ToggleHideOffline"
#define MS_CLIST_TOGGLESOUNDS "CList/ToggleSounds"
// Add new object to skin object list.
// wParam = pointer to SKINOBJECTDESCRIPTOR structure
// lParam = 0 ( used for internal purposes: pointer to skin object list)
#define MS_SKIN_REGISTEROBJECT "ModernList/RegisterObject"
// Add new object to skin object list.
// wParam = pointer to DEF_SKIN_OBJECT_PARAMS structure
// lParam = 0 ( used for internal purposes: pointer to skin object list)
#define MS_SKIN_REGISTERDEFOBJECT "ModernList/RegisterDefObject"
typedef struct s_DEF_SKIN_OBJECT_PARAMS
{
char * szObjectID;
BYTE defStyle;
DWORD defColor;
// SKINOBJECTSLIST * Skin;
} DEF_SKIN_OBJECT_PARAMS;
// Request painting glyph object
// wParam = pointer to SKINDRAWREQUEST structure
// lParam = 0
#define MS_SKIN_DRAWGLYPH "ModernList/DrawGlyph"
/* EVENTS */
#define ME_SKIN_SERVICESCREATED "ModernList/ServicesCreated"
/* DRAWGLYPH Request structure */
typedef struct s_SKINDRAWREQUEST
{
char szObjectID[255]; // Unic Object ID (path) to paint
RECT rcDestRect; // Rectangle to fit
RECT rcClipRect; // Rectangle to paint in.
HDC hDC; // Handler to device context to paint in.
} SKINDRAWREQUEST,*LPSKINDRAWREQUEST;
/* SKINOBJECTDESCRIPTOR opbject descriptor structure */
typedef struct tagSKINOBJECTDESCRIPTOR
{
BYTE bType; // One of OT_* values.
char* szObjectID; // Unic Object ID (path) [255] max
LPVOID Data; // Pointer to GLYPHOBJECT strycture if bType==OT_GLYPHOBJECT
} SKINOBJECTDESCRIPTOR, *LPSKINOBJECTDESCRIPTOR;
/* SKINOBJECTDESCRIPTOR opbject descriptor structure */
typedef struct s_GLYPHOBJECT
{
BYTE Style; // One of ST_* values
HBITMAP hGlyph; // Bitmap handler (for internal use only)
DWORD dwTop, dwLeft, dwBottom, dwRight; // Margins
char* szFileName; // FileName of image
DWORD dwColor; // Fill color
BYTE dwAlpha; // Constant alpha-transparency level
BYTE FitMode; // One of FM_* values
POINT clipArea; // Object image rect on full image
SIZE szclipArea; // Object image rect on full image
SortedList * plTextList; // List of GLYPHTEXT
LONG bmWidth;
LONG bmHeight;
BYTE bmBitsPixel;
} GLYPHOBJECT,*LPGLYPHOBJECT;
/* SKINTEXTDESCRIPTOR opbject descriptor structure */
typedef struct s_GLYPHTEXT
{
char * szGlyphTextID;
TCHAR * stText;
TCHAR * stValueText;
DWORD dwFlags;
DWORD dwColor; // Color (InvAA)(RR)(GG)(BB)
DWORD dwShadow; //ToDo: Color2/Shaddow
int iLeft,iTop,iRight,iBottom;
BYTE RelativeFlags;
char * szFontID;
HFONT hFont;
char * szObjectName;
}GLYPHTEXT,*LPGLYPHTEXT;
/* SKINTEXTDESCRIPTOR opbject descriptor structure */
typedef struct s_SKINFONT
{
char * szFontID;
HFONT hFont;
}SKINFONT, *LPSKINFONT;
/* HELPER FUNCTIONS */
//Paint ObjectID as parent background for frame hwndIn
int __inline SkinDrawWindowBack(HWND hwndIn, HDC hdc, RECT * rcClip, char * objectID)
{
SKINDRAWREQUEST rq;
POINT pt={0};
RECT rc,r1;
if (!objectID) return 0;
GetWindowRect(hwndIn,&r1);
pt.x=r1.left;
pt.y=r1.top;
GetWindowRect(pcli->hwndContactList, &rc);
OffsetRect(&rc,-pt.x ,-pt.y);
rq.hDC=hdc;
rq.rcDestRect=rc;
rq.rcClipRect=*rcClip;
lstrcpynA(rq.szObjectID,objectID,sizeof(rq.szObjectID));
///ske_Service_DrawGlyph((WPARAM)&rq,0); //$$$
return CallService(MS_SKIN_DRAWGLYPH,(WPARAM)&rq,0);
}
//Register object with predefined style
int __inline CreateGlyphedObjectDefStyle(char * ObjID,BYTE defStyle);
int __inline CreateGlyphedObjectDefColor(char * ObjID,DWORD defColor);
//Register default object
int __inline CreateGlyphedObject(char * ObjID);
//// Creating and registering objects
//int __inline CreateGlyphedObject(char * ObjID)
//{
// DEF_SKIN_OBJECT_PARAMS prm={0};
// prm.defColor=DEFAULT_BKCOLOUR;
// prm.defStyle=DEFAULT_STYLE;
// prm.szObjectID=ObjID;
// return CallService(MS_SKIN_REGISTERDEFOBJECT,(WPARAM)&prm,0);
//}
static BOOL __inline ScreenToClientRect(HWND hWnd, LPRECT lpRect)
{
BOOL ret;
POINT pt;
pt.x = lpRect->left;
pt.y = lpRect->top;
ret = ScreenToClient(hWnd, &pt);
if (!ret) return ret;
lpRect->left = pt.x;
lpRect->top = pt.y;
pt.x = lpRect->right;
pt.y = lpRect->bottom;
ret = ScreenToClient(hWnd, &pt);
lpRect->right = pt.x;
lpRect->bottom = pt.y;
return ret;
}
//int __inline CreateGlyphedObjectDefStyle(char * ObjID,BYTE defStyle)
//{
// DEF_SKIN_OBJECT_PARAMS prm={0};
// prm.defColor=DEFAULT_BKCOLOUR;
// prm.defStyle=defStyle;
// prm.szObjectID=ObjID;
// return CallService(MS_SKIN_REGISTERDEFOBJECT,(WPARAM)&prm,0);
//}
//int __inline CreateGlyphedObjectDefColor(char * ObjID,DWORD defColor)
//{
// DEF_SKIN_OBJECT_PARAMS prm={0};
// prm.defColor=defColor;
// prm.defStyle=ST_BRUSH;
// prm.szObjectID=ObjID;
// return CallService(MS_SKIN_REGISTERDEFOBJECT,(WPARAM)&prm,0);
//}
//Paint ObjectID
static int __inline SkinDrawGlyph(HDC hdc, RECT * rcSize, RECT * rcClip, char * objectID)
{
SKINDRAWREQUEST rq;
if (!objectID) return 0;
rq.hDC=hdc;
rq.rcDestRect=*rcSize;
rq.rcClipRect=*rcClip;
lstrcpynA(rq.szObjectID,objectID,sizeof(rq.szObjectID));
return CallService(MS_SKIN_DRAWGLYPH,(WPARAM)&rq,0);
}
//#include "../hdr/modern_skin_selector.h"
//////////////////////////////////////////////
// //
// New Painting sequence servises //
// //
//////////////////////////////////////////////
typedef struct sPAINT_REQUEST
{
DWORD dStructSize; //size of structure
HWND hWnd; //called by window
HDC hDC; //context to draw on
RECT rcUpdate; //rectangle to be painted in (relative to Top-Left corner of Main window)
DWORD dwFlags; //drawing flags
void * CallbackData; //Data for passing to callback procedure
char Reserved[16]; //reserved for farther usage;
} sPaintRequest;
// Request to register sub for callback painting frame area
// wParam = hWnd of called frame
// lParam = pointer to tPaintCallBackProc (or NULL to remove)
// return 1 - succes, 0 - failure
#define MS_SKINENG_REGISTERPAINTSUB "SkinEngine/ske_Service_RegisterFramePaintCallbackProcedure"
// Request to repaint frame or change/drop callback data immeadeately
// wParam = hWnd of called frame
// lParam = pointer to sPaintRequest (or NULL to redraw all)
#define MS_SKINENG_UPTATEFRAMEIMAGE "SkinEngine/ske_Service_UpdateFrameImage"
// Request to repaint frame or change/drop callback data
// wParam = hWnd of called frame
// lParam = pointer to sPaintRequest (or NULL to redraw all)
// return 2 - already queued, data updated, 1-have been queued, 0 - failure
#define MS_SKINENG_INVALIDATEFRAMEIMAGE "SkinEngine/ske_Service_InvalidateFrameImage"
// Callback proc type
typedef int (/*__stdcall*/ *tPaintCallbackProc)(HWND hWnd, HDC hDC, RECT * rcPaint, HRGN rgnUpdate, DWORD dFlags, void * CallBackData);
//tPaintCallbackProc PaintCallbackProc;
// HELPER TO UPDATEIMAGEFRAME
__inline BOOL isSkinEngineEnabled()
{
return ServiceExists(MS_SKINENG_REGISTERPAINTSUB) && !db_get_b(NULL, "ModernData", "DisableEngine", FALSE);
}
__inline BOOL isLayeredEnabled()
{
return isSkinEngineEnabled() && db_get_b(NULL, "ModernData", "EnableLayering", TRUE);
}
int __inline SkinEngUpdateImageFrame(HWND hwnd, RECT * rcUpdate, DWORD dwFlags, void * CallBackData)
{
sPaintRequest sr={0};
sr.dStructSize=sizeof(sPaintRequest);
sr.hWnd=hwnd;
if (rcUpdate)
sr.rcUpdate=*rcUpdate;
sr.dwFlags=dwFlags;
sr.CallbackData=CallBackData;
return CallService(MS_SKINENG_UPTATEFRAMEIMAGE,(WPARAM)hwnd,(LPARAM)&sr);
}
int __inline SkinEngInvalidateImageFrame(HWND hwnd, CONST RECT * rcUpdate, DWORD dwFlags, void * CallBackData)
{
sPaintRequest sr={0};
if (hwnd && !isLayeredEnabled()) return InvalidateRect(hwnd,rcUpdate,dwFlags);
sr.dStructSize=sizeof(sPaintRequest);
sr.hWnd=hwnd;
if (rcUpdate)
sr.rcUpdate=*rcUpdate;
sr.dwFlags=dwFlags;
sr.CallbackData=CallBackData;
return CallService(MS_SKINENG_INVALIDATEFRAMEIMAGE,(WPARAM)hwnd,(LPARAM)&sr);
}
int __inline SkinInvalidateFrame(HWND hWnd, CONST RECT* lpRect)
{
return SkinEngInvalidateImageFrame(hWnd, lpRect, 0, 0);
}
// Alpha channel GDI replacements/helpers
//
// Paints text with correct alpha channel
// wParam - pointer to AlphaTextOutParams
#define MS_SKINENG_ALPHATEXTOUT "SkinEngine/ske_AlphaTextOut"
typedef struct _AlphaTextOutParams
{
HDC hDC;
LPCTSTR lpString;
int nCount;
RECT * lpRect;
UINT format;
DWORD ARGBcolor;
char reserv[16];
}AlphaTextOutParams;
int __inline AlphaText(HDC hDC, LPCTSTR lpString, int nCount, RECT * lpRect, UINT format, DWORD ARGBcolor)
{
AlphaTextOutParams ap={0};
ap.hDC=hDC;
ap.lpString=lpString;
ap.nCount=nCount;
ap.lpRect=lpRect;
ap.format=format;
ap.ARGBcolor=ARGBcolor;
return CallService(MS_SKINENG_ALPHATEXTOUT,(WPARAM)&ap,0);
}
////////////////////////////////////////////////////////////////////////////////
// Paints text with correct alpha channel and effect, alternative to DrawText
// wParam - pointer to DrawTextWithEffectParam
typedef struct MODERNFONTEFFECT_tag
{
BYTE effectIndex;
DWORD baseColour; // ARGB
DWORD secondaryColour; // ARGB
}
MODERNFONTEFFECT;
typedef struct DrawTextWithEffectParam_tag
{
int cbSize;
HDC hdc; // handle to DC
LPCTSTR lpchText; // text to draw
int cchText; // length of text to draw
LPRECT lprc; // rectangle coordinates
UINT dwDTFormat; // formatting options
MODERNFONTEFFECT * pEffect; // effect to be drawn on
} DrawTextWithEffectParam;
#define MS_DRAW_TEXT_WITH_EFFECTA "Modern/SkinEngine/DrawTextWithEffectA"
#define MS_DRAW_TEXT_WITH_EFFECTW "Modern/SkinEngine/DrawTextWithEffectW"
#ifdef UNICODE
#define MS_DRAW_TEXT_WITH_EFFECT MS_DRAW_TEXT_WITH_EFFECTW
#else
#define MS_DRAW_TEXT_WITH_EFFECT MS_DRAW_TEXT_WITH_EFFECTA
#endif
// Helper
int __inline DrawTextWithEffect( HDC hdc, LPCTSTR lpchText, int cchText, RECT * lprc, UINT dwDTFormat, MODERNFONTEFFECT * pEffect )
{
DrawTextWithEffectParam params;
static BYTE bIfServiceExists = ServiceExists( MS_DRAW_TEXT_WITH_EFFECT ) ? 1 : 0;
if ( bIfServiceExists == 0 ) return DrawText ( hdc, lpchText, cchText, lprc, dwDTFormat );
// else
params.cbSize = sizeof( DrawTextWithEffectParam );
params.hdc = hdc;
params.lpchText = lpchText;
params.cchText = cchText;
params.lprc = lprc;
params.dwDTFormat = dwDTFormat;
params.pEffect = pEffect;
return CallService( MS_DRAW_TEXT_WITH_EFFECT, (WPARAM)¶ms, 0 );
}
typedef struct _ImageListFixParam
{
HIMAGELIST himl;
int index;
HICON hicon;
}ImageListFixParam;
typedef struct _DrawIconFixParam
{
HDC hdc;
int xLeft;
int yTop;
HICON hIcon;
int cxWidth;
int cyWidth;
UINT istepIfAniCur;
HBRUSH hbrFlickerFreeDraw;
UINT diFlags;
} DrawIconFixParam;
//wParam - pointer to DrawIconFixParam
#define MS_SKINENG_DRAWICONEXFIX "SkinEngine/DrawIconEx_Fix"
int __inline mod_DrawIconEx_helper(HDC hdc,int xLeft,int yTop,HICON hIcon,int cxWidth,int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
{
DrawIconFixParam p={0};
p.hdc=hdc;
p.xLeft=xLeft;
p.yTop=yTop;
p.hIcon=hIcon;
p.cxWidth=cxWidth;
p.cyWidth=cyWidth;
p.istepIfAniCur=istepIfAniCur;
p.hbrFlickerFreeDraw=hbrFlickerFreeDraw;
p.diFlags=diFlags;
return CallService(MS_SKINENG_DRAWICONEXFIX,(WPARAM)&p,0);
}
// Register of plugin's user
//
// wParam = (WPARAM)szSetting - string that describes a user
// format: Category/ModuleName,
// eg: "Contact list background/CLUI",
// "Status bar background/StatusBar"
// lParam = (LPARAM)dwFlags
//
#define MS_BACKGROUNDCONFIG_REGISTER "ModernBkgrCfg/Register"
//
// Notification about changed background
// wParam = ModuleName
// lParam = 0
#define ME_BACKGROUNDCONFIG_CHANGED "ModernBkgrCfg/Changed"
#endif
|