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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
|
/*
Miranda IM: the free IM client for Microsoft* Windows*
Copyright 2000-2008 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.
*/
#include "hdr/modern_commonheaders.h"
#include "m_clui.h"
#include "hdr/modern_clist.h"
#include "m_clc.h"
#include "io.h"
#include "hdr/modern_commonprototypes.h"
#include "hdr/modern_sync.h"
typedef struct _OPT_OBJECT_DATA
{
char * szName;
char * szPath;
char * szValue;
char * szTempValue;
} OPT_OBJECT_DATA;
static char *gl_Mask = NULL;
HWND gl_Dlg = NULL;
int gl_controlID = 0;
int EnableGroup(HWND hwndDlg, HWND first, BOOL bEnable);
int ShowGroup(HWND hwndDlg, HWND first, BOOL bEnable);
BOOL glOtherSkinWasLoaded = FALSE;
BYTE glSkinWasModified = 0; //1- but not applied, 2-stored to DB
HTREEITEM FindChild(HWND hTree, HTREEITEM Parent, char * Caption)
{
HTREEITEM res = NULL, tmp = NULL;
if (Parent)
tmp = TreeView_GetChild(hTree,Parent);
else
tmp = TreeView_GetRoot(hTree);
while (tmp)
{
TVITEMA tvi;
char buf[255];
tvi.hItem = tmp;
tvi.mask = TVIF_TEXT|TVIF_HANDLE;
tvi.pszText = (LPSTR)&buf;
tvi.cchTextMax = 254;
TreeView_GetItemA(hTree,&tvi);
if (mir_bool_strcmpi(Caption,tvi.pszText))
return tmp;
tmp = TreeView_GetNextSibling(hTree,tmp);
}
return tmp;
}
int TreeAddObject(HWND hwndDlg, int ID, OPT_OBJECT_DATA * data)
{
HTREEITEM rootItem = NULL;
HTREEITEM cItem = NULL;
char * path;
char * ptr;
char * ptrE;
char buf[255];
BOOL ext = FALSE;
path = data->szPath?mir_strdup(data->szPath):(data->szName[1] == '$')?mir_strdup((data->szName)+2):NULL;
if ( !path) {
mir_snprintf(buf,SIZEOF(buf),"$(other)/%s",(data->szName)+1);
path = mir_strdup(buf);
}
ptr = path;
ptrE = path;
do
{
while (*ptrE != '/' && *ptrE != '\0') ptrE++;
if (*ptrE == '/')
{
*ptrE = '\0';
ptrE++;
// find item if not - create;
{
cItem = FindChild(GetDlgItem(hwndDlg,ID),rootItem,ptr);
if ( !cItem) // not found - create node
{
TVINSERTSTRUCTA tvis;
tvis.hParent = rootItem;
tvis.hInsertAfter = TVI_SORT;
tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_PARAM;
tvis.item.pszText = ptr;
tvis.item.lParam = 0;
cItem = TreeView_InsertItemA(GetDlgItem(hwndDlg,ID),&tvis);
}
rootItem = cItem;
}
ptr = ptrE;
}
else ext = TRUE;
}while (!ext);
//Insert item node
{
TVINSERTSTRUCTA tvis;
tvis.hParent = rootItem;
tvis.hInsertAfter = TVI_SORT;
tvis.item.mask = TVIF_PARAM|TVIF_TEXT|TVIF_PARAM;
tvis.item.pszText = ptr;
tvis.item.lParam = (LPARAM)data;
TreeView_InsertItemA(GetDlgItem(hwndDlg,ID),&tvis);
}
mir_free(path);
return 0;
}
int enumDB_SkinObjectsForEditorProc(const char *szSetting,LPARAM lParam)
{
if (wildcmp((char *)szSetting,gl_Mask,0) || wildcmp((char *)szSetting,"$*",0))
{
char * value;
char *desc;
char *descKey;
descKey = mir_strdup(szSetting);
descKey[0] = '%';
value = db_get_sa(NULL,SKIN,szSetting);
desc = db_get_sa(NULL,SKIN,descKey);
if (wildcmp(value,"?lyph*",0))
{
OPT_OBJECT_DATA * a = (OPT_OBJECT_DATA*)mir_alloc(sizeof(OPT_OBJECT_DATA));
a->szPath = desc;
a->szName = mir_strdup(szSetting);
a->szValue = value;
a->szTempValue = NULL;
TreeAddObject(gl_Dlg,gl_controlID,a);
}
else {
mir_free(value);
mir_free(desc);
}
mir_free(descKey);
}
return 0;
}
int FillObjectTree(HWND hwndDlg, int ObjectTreeID, char * wildmask)
{
DBCONTACTENUMSETTINGS dbces;
gl_Dlg = hwndDlg;
gl_controlID = ObjectTreeID;
gl_Mask = wildmask;
dbces.pfnEnumProc = enumDB_SkinObjectsForEditorProc;
dbces.szModule = SKIN;
dbces.ofsSettings = 0;
CallService(MS_DB_CONTACT_ENUMSETTINGS, 0, (LPARAM)&dbces);
return 0;
}
TCHAR *TYPES[] = {_T("- Empty - (do not draw this object)"),_T("Solid fill object"),_T("Image (draw image)"),_T("Fragment (draw portion of image)")};
TCHAR *FITMODES[] = {_T("Stretch Both directions"),_T("Stretch Vertical, Tile Horizontal"),_T("Tile Vertical, Stretch Horizontal"),_T("Tile Both directions")};
void SetAppropriateGroups(HWND hwndDlg, int Type)
//str contains default values
{
switch (Type)
{
case -1:
{
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE);
ShowWindow(GetDlgItem(hwndDlg,IDC_S_SIZE),FALSE);
}
break;
case 0:
{
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE);
ShowWindow(GetDlgItem(hwndDlg,IDC_S_SIZE),FALSE);
}
break;
case 1:
{
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE);
ShowWindow(GetDlgItem(hwndDlg,IDC_S_SIZE),FALSE);
//Set Color and alpha
}
break;
case 2:
{
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE);
ShowWindow(GetDlgItem(hwndDlg,IDC_S_SIZE),TRUE);
//Set alpha, image, margins etc.
}
break;
case 3:
{
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),TRUE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),TRUE);
ShowWindow(GetDlgItem(hwndDlg,IDC_S_SIZE),TRUE);
//Set alpha, image, margins etc.
}
break;
}
}
void SetControls(HWND hwndDlg, char * str)
{
char buf[250];
int Type=0;
if ( !str)
{
SetAppropriateGroups(hwndDlg,-1);
return;
}
GetParamN(str,buf,SIZEOF(buf),1,',',TRUE);
if (mir_bool_strcmpi(buf,"Solid")) Type=1;
else if (mir_bool_strcmpi(buf,"Image")) Type=2;
else if (mir_bool_strcmpi(buf,"Fragment")) Type=3;
SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_SETCURSEL,(WPARAM)Type,0);
SetAppropriateGroups(hwndDlg,Type);
switch (Type)
{
case 1:
{
int r,g,b,a;
r = g = b = 200;
a = 255;
r = atoi(GetParamN(str,buf,SIZEOF(buf),2,',',TRUE));
g = atoi(GetParamN(str,buf,SIZEOF(buf),3,',',TRUE));
b = atoi(GetParamN(str,buf,SIZEOF(buf),4,',',TRUE));
a = atoi(GetParamN(str,buf,SIZEOF(buf),5,',',TRUE));
SendDlgItemMessage(hwndDlg,IDC_COLOR,CPM_SETCOLOUR, 0, (LPARAM)RGB(r,g,b));
SendDlgItemMessage(hwndDlg,IDC_COLOR,CPM_SETDEFAULTCOLOUR, 0, (LPARAM)RGB(r,g,b));
SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETPOS, 0, MAKELONG(a,0));
}
break;
case 2:
{
int a;
int l,t,r,b;
int fitmode = 0;
l = t = r = b = 0;
a = 255;
l = atoi(GetParamN(str,buf,SIZEOF(buf),4,',',TRUE));
t = atoi(GetParamN(str,buf,SIZEOF(buf),5,',',TRUE));
r = atoi(GetParamN(str,buf,SIZEOF(buf),6,',',TRUE));
b = atoi(GetParamN(str,buf,SIZEOF(buf),7,',',TRUE));
a = atoi(GetParamN(str,buf,SIZEOF(buf),8,',',TRUE));
SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETPOS, 0, MAKELONG(a,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_SETPOS, 0, MAKELONG(l,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_SETPOS, 0, MAKELONG(t,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_SETPOS, 0, MAKELONG(r,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_SETPOS, 0, MAKELONG(b,0));
GetParamN(str,buf,SIZEOF(buf),2,',',TRUE);
SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_SETTEXT, 0, (LPARAM)buf);
GetParamN(str,buf,SIZEOF(buf),3,',',TRUE);
if (mir_bool_strcmpi(buf,"TileBoth")) fitmode = FM_TILE_BOTH;
else if (mir_bool_strcmpi(buf,"TileVert")) fitmode = FM_TILE_VERT;
else if (mir_bool_strcmpi(buf,"TileHorz")) fitmode = FM_TILE_HORZ;
else fitmode = 0;
SendDlgItemMessage(hwndDlg,IDC_FIT,CB_SETCURSEL,(WPARAM)fitmode,0);
}
break;
case 3:
{
int a;
int l,t,r,b;
int x,y,w,h;
int fitmode = 0;
l = t = r = b = 0;
x = y = w = h = 0;
a = 255;
x = atoi(GetParamN(str,buf,SIZEOF(buf),3,',',TRUE));
y = atoi(GetParamN(str,buf,SIZEOF(buf),4,',',TRUE));
w = atoi(GetParamN(str,buf,SIZEOF(buf),5,',',TRUE));
h = atoi(GetParamN(str,buf,SIZEOF(buf),6,',',TRUE));
l = atoi(GetParamN(str,buf,SIZEOF(buf),8,',',TRUE));
t = atoi(GetParamN(str,buf,SIZEOF(buf),9,',',TRUE));
r = atoi(GetParamN(str,buf,SIZEOF(buf),10, ',',TRUE));
b = atoi(GetParamN(str,buf,SIZEOF(buf),11,',',TRUE));
a = atoi(GetParamN(str,buf,SIZEOF(buf),12,',',TRUE));
SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETPOS, 0, MAKELONG(a,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_SETPOS, 0, MAKELONG(l,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_SETPOS, 0, MAKELONG(t,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_SETPOS, 0, MAKELONG(r,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_SETPOS, 0, MAKELONG(b,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_POSLEFT,UDM_SETPOS, 0, MAKELONG(x,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_POSTOP,UDM_SETPOS, 0, MAKELONG(y,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_WIDTH,UDM_SETPOS, 0, MAKELONG(w,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_HEIGHT,UDM_SETPOS, 0, MAKELONG(h,0));
GetParamN(str,buf,SIZEOF(buf),2,',',TRUE);
SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_SETTEXT, 0, (LPARAM)buf);
GetParamN(str,buf,SIZEOF(buf),7,',',TRUE);
if (mir_bool_strcmpi(buf,"TileBoth")) fitmode = FM_TILE_BOTH;
else if (mir_bool_strcmpi(buf,"TileVert")) fitmode = FM_TILE_VERT;
else if (mir_bool_strcmpi(buf,"TileHorz")) fitmode = FM_TILE_HORZ;
else fitmode = 0;
SendDlgItemMessage(hwndDlg,IDC_FIT,CB_SETCURSEL,(WPARAM)fitmode,0);
}
break;
}
}
int GetShortFileName(TCHAR *FullFile)
{
TCHAR buf[MAX_PATH] = {0};
TCHAR *f = _tcsrchr(FullFile,'\\');
TCHAR *file = f ? mir_tstrdup(f+1) : 0;
if ( !file)
return 0;
ske_GetFullFilename(buf, file, 0, TRUE);
if ( mir_bool_tstrcmpi(buf, FullFile)) {
_tcsncpy(FullFile, file, MAX_PATH);
mir_free(file);
return 1; //skin folder relative
}
PathToRelativeT(FullFile, buf);
if (buf[0] != '\\' && buf[1] != ':')
mir_sntprintf(FullFile, MAX_PATH, _T("\\%s"), buf);
else
_tcsncpy(FullFile, buf, MAX_PATH);
mir_free(file);
return 2; //mirand folder relative
}
char * MadeString(HWND hwndDlg)
{
char buf[MAX_PATH*2] = {0};
int i = SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_GETCURSEL, 0, 0);
switch (i)
{
case 0:
mir_snprintf(buf,SIZEOF(buf),"Glyph,Skip");
break;
case 1:
{
BYTE a;
DWORD col;
a = (BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_GETPOS, 0, 0);
col = (DWORD)SendDlgItemMessage(hwndDlg,IDC_COLOR,CPM_GETCOLOUR, 0, 0);
mir_snprintf(buf,SIZEOF(buf),"Glyph,Solid,%d,%d,%d,%d",GetRValue(col),GetGValue(col),GetBValue(col),a);
}
break;
case 2:
{
BYTE a;
WORD l,t,b,r;
char buf_name[MAX_PATH] = {0};
int i=0;
a = (BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_GETPOS, 0, 0);
l = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_GETPOS, 0, 0);
t = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_GETPOS, 0, 0);
r = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_GETPOS, 0, 0);
b = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_GETPOS, 0, 0);
SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_GETTEXT,(WPARAM)MAX_PATH,(LPARAM)buf_name);
i = SendDlgItemMessage(hwndDlg,IDC_FIT,CB_GETCURSEL, 0, 0);
mir_snprintf(buf,SIZEOF(buf),"Glyph,Image,%s,%s,%d,%d,%d,%d,%d",buf_name,
//fitmode
(i == FM_TILE_BOTH)?"TileBoth":
(i == FM_TILE_VERT)?"TileVert":
(i == FM_TILE_HORZ)?"TileHorz":"StretchBoth",
l,t,r,b,a);
}
break;
case 3:
{
BYTE a;
WORD l,t,b,r;
WORD x,y,w,h;
char buf_name[MAX_PATH] = {0};
int i=0;
a = (BYTE)SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_GETPOS, 0, 0);
l = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_GETPOS, 0, 0);
t = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_GETPOS, 0, 0);
r = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_GETPOS, 0, 0);
b = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_GETPOS, 0, 0);
x = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_POSLEFT,UDM_GETPOS, 0, 0);
y = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_POSTOP,UDM_GETPOS, 0, 0);
w = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_WIDTH,UDM_GETPOS, 0, 0);
h = (WORD)SendDlgItemMessage(hwndDlg,IDC_SPIN_HEIGHT,UDM_GETPOS, 0, 0);
SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_GETTEXT,(WPARAM)MAX_PATH,(LPARAM)buf_name);
i = SendDlgItemMessage(hwndDlg,IDC_FIT,CB_GETCURSEL, 0, 0);
mir_snprintf(buf,SIZEOF(buf),"Glyph,Fragment,%s,%d,%d,%d,%d,%s,%d,%d,%d,%d,%d",buf_name,x,y,w,h,
//fitmode
(i == FM_TILE_BOTH)?"TileBoth":
(i == FM_TILE_VERT)?"TileVert":
(i == FM_TILE_HORZ)?"TileHorz":"StretchBoth",
l,t,r,b,a);
}
break;
}
if (buf[0] != '\0') return mir_strdup(buf);
return 0;
}
void UpdateInfo(HWND hwndDlg)
{
char *b = MadeString(hwndDlg);
if ( !b)
{
SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT, 0, (LPARAM)"");
return;
}
SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT, 0, (LPARAM)b);
{
OPT_OBJECT_DATA *sd = NULL;
HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_OBJECT_TREE));
if (hti)
{
TVITEMA tvi = {0};
tvi.hItem = hti;
tvi.mask = TVIF_HANDLE|TVIF_PARAM;
TreeView_GetItem(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),&tvi);
sd = (OPT_OBJECT_DATA*)(tvi.lParam);
if (sd)
{
mir_free(sd->szValue);
sd->szValue = mir_strdup(b);
}
}
}
mir_free(b);
glSkinWasModified = 1;
}
void StoreTreeNode(HWND hTree, HTREEITEM node, char * section)
{
HTREEITEM tmp;
tmp = node;
while (tmp)
{
HTREEITEM tmp2 = NULL;
TVITEMA tvi;
char buf[255];
tvi.hItem = tmp;
tvi.mask = TVIF_TEXT|TVIF_HANDLE;
tvi.pszText = (LPSTR)&buf;
tvi.cchTextMax = 254;
TreeView_GetItemA(hTree,&tvi);
if (tvi.lParam)
{
OPT_OBJECT_DATA * dat = (OPT_OBJECT_DATA*)(tvi.lParam);
if (dat->szName && dat->szValue)
db_set_s(NULL,section,dat->szName,dat->szValue);
}
tmp2 = TreeView_GetChild(hTree,tmp);
if (tmp2) StoreTreeNode(hTree,tmp2,section);
tmp = TreeView_GetNextSibling(hTree,tmp);
}
return;
}
void StoreTreeToDB(HWND hTree, char * section)
{
HTREEITEM tmp = NULL;
tmp = TreeView_GetRoot(hTree);
StoreTreeNode(hTree,tmp,section);
db_set_b(NULL,section,"Modified",1);
glSkinWasModified = 2;
}
static BOOL fileChanged = FALSE;
static char * object_clipboard = NULL;
int GetFileSizes(HWND hwndDlg)
{
TCHAR buf[MAX_PATH];
SIZE sz = {0};
SendDlgItemMessageA(hwndDlg,IDC_FILE,WM_GETTEXT,(WPARAM)MAX_PATH,(LPARAM)buf);
ske_GetFullFilename(buf, buf, 0, TRUE);
HBITMAP hbmp = ske_LoadGlyphImage(buf);
if (hbmp) {
BITMAP bm = {0};
GetObject(hbmp,sizeof(BITMAP),&bm);
sz.cx = bm.bmWidth;
sz.cy = bm.bmHeight;
ske_UnloadGlyphImage(hbmp);
}
mir_sntprintf(buf, MAX_PATH, _T("%s %d x %d %s"),TranslateT("Image size is"), sz.cx, sz.cy, TranslateT("pixels"));
SetDlgItemText(hwndDlg, IDC_S_SIZE, buf);
return 0;
}
INT_PTR CALLBACK DlgSkinEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_WINDOWPOSCHANGED:
{
WINDOWPOS * wp = (WINDOWPOS *)lParam;
if (lParam && wp->flags&SWP_SHOWWINDOW)
{
if (glOtherSkinWasLoaded)
{
TreeView_DeleteAllItems(GetDlgItem(hwndDlg,IDC_OBJECT_TREE));
FillObjectTree(hwndDlg,IDC_OBJECT_TREE,"$$*");
glSkinWasModified = 0;
glOtherSkinWasLoaded = FALSE;
}
}
break;
}
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
FillObjectTree(hwndDlg,IDC_OBJECT_TREE,"$$*");
{ //Fill types combo
int i=0;
for (i=0; i < SIZEOF(TYPES); i++)
SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_ADDSTRING, 0, (LPARAM)TranslateTS(TYPES[i]));
}
{ //Fill fit combo
int i=0;
for (i=0; i < SIZEOF(FITMODES); i++)
SendDlgItemMessage(hwndDlg,IDC_FIT,CB_ADDSTRING, 0, (LPARAM)TranslateTS(FITMODES[i]));
}
//SPIN Ranges
{
SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETRANGE, 0, MAKELONG(255,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_ALPHA,UDM_SETPOS, 0, MAKELONG(255,0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_TOP,UDM_SETRANGE, 0, MAKELONG(900, 0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_LEFT,UDM_SETRANGE, 0, MAKELONG(900, 0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_BOTTOM,UDM_SETRANGE, 0, MAKELONG(900, 0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_RIGHT,UDM_SETRANGE, 0, MAKELONG(900, 0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_POSLEFT,UDM_SETRANGE, 0, MAKELONG(1000, 0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_POSTOP,UDM_SETRANGE, 0, MAKELONG(1000, 0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_WIDTH,UDM_SETRANGE, 0, MAKELONG(1000, 0));
SendDlgItemMessage(hwndDlg,IDC_SPIN_HEIGHT,UDM_SETRANGE, 0, MAKELONG(1000, 0));
}
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_1),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_COLOUR),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_ST_ALPHA),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_2),FALSE);
EnableGroup(hwndDlg,GetDlgItem(hwndDlg,IDC_GROUP_3),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE);
glSkinWasModified = 0;
glOtherSkinWasLoaded = FALSE;
break;
case WM_COMMAND:
{
if (LOWORD(wParam) == IDC_TYPE)
{
if (HIWORD(wParam) == CBN_SELCHANGE)
{
int i = SendDlgItemMessage(hwndDlg,IDC_TYPE,CB_GETCURSEL, 0, 0);
//if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_TYPE)))
SetAppropriateGroups(hwndDlg,i);
if (GetFocus() == GetDlgItem(hwndDlg,IDC_TYPE))
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
UpdateInfo(hwndDlg);
break;
}
}
else if (LOWORD(wParam) == IDC_COPY)
{
if (HIWORD(wParam) == BN_CLICKED)
{
mir_free_and_nil(object_clipboard);
OPT_OBJECT_DATA *sd = NULL;
HTREEITEM hti = TreeView_GetSelection(GetDlgItem(hwndDlg,IDC_OBJECT_TREE));
if (hti != 0)
{
TVITEM tvi = {0};
tvi.hItem = hti;
tvi.mask = TVIF_HANDLE|TVIF_PARAM;
TreeView_GetItem(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),&tvi);
sd = (OPT_OBJECT_DATA*)(tvi.lParam);
}
if (sd && sd->szValue)
object_clipboard = mir_strdup(sd->szValue);
EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),object_clipboard != NULL);
return 0;
}
}
else if (LOWORD(wParam) == IDC_PASTE)
{
if (HIWORD(wParam) == BN_CLICKED)
{
if (object_clipboard)
SetControls(hwndDlg, object_clipboard);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
UpdateInfo(hwndDlg);
return 0;
}
}
else if (LOWORD(wParam) == IDC_COLOR)
{
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
UpdateInfo(hwndDlg);
}
else if (LOWORD(wParam) == IDC_BROWSE) {
if (HIWORD(wParam) == BN_CLICKED) {
TCHAR str[MAX_PATH] = {0};
OPENFILENAME ofn = {0};
TCHAR filter[512] = {0};
int res = 0;
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwndDlg;
ofn.hInstance = NULL;
ofn.lpstrFilter = _T("Images (*.png,*.jpg,*.bmp,*.gif,*.tga)\0*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.tga\0All files (*.*)\0*.*\0\0");
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
GetDlgItemText(hwndDlg, IDC_FILE, str, SIZEOF(str));
if (str[0] == '\0' || _tcschr(str,'%')) {
ofn.Flags |= OFN_NOVALIDATE;
str[0] = '\0';
}
else ske_GetFullFilename(str, str, 0, TRUE);
ofn.lpstrFile = str;
ofn.nMaxFile = SIZEOF(str);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = _T("*.*");
res = GetOpenFileName(&ofn);
if (res) {
GetShortFileName(ofn.lpstrFile);
SetDlgItemText(hwndDlg, IDC_FILE, ofn.lpstrFile);
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
UpdateInfo(hwndDlg);
}
}
}
else if (LOWORD(wParam) == IDC_FILE)
{
if (HIWORD(wParam) == EN_CHANGE)
{
fileChanged = TRUE;
if ((HWND)lParam != GetFocus())
{
GetFileSizes(hwndDlg);
fileChanged = FALSE;
}
}
else if (HIWORD(wParam) == EN_KILLFOCUS)
{
if (fileChanged)
{
GetFileSizes(hwndDlg);
fileChanged = FALSE;
}
}
}
else if ((
(LOWORD(wParam) == IDC_E_TOP
|| LOWORD(wParam) == IDC_E_BOTTOM
|| LOWORD(wParam) == IDC_E_LEFT
|| LOWORD(wParam) == IDC_E_RIGHT
|| LOWORD(wParam) == IDC_E_X
|| LOWORD(wParam) == IDC_E_Y
|| LOWORD(wParam) == IDC_E_W
|| LOWORD(wParam) == IDC_E_H
|| LOWORD(wParam) == IDC_EDIT_ALPHA
)
&& HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
{
return 0;
}
else if (LOWORD(wParam) != IDC_EDIT1)
{
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
UpdateInfo(hwndDlg);
}
break;
}
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->idFrom) {
case IDC_OBJECT_TREE:
{
NMTREEVIEWA * nmtv = (NMTREEVIEWA *) lParam;
if ( !nmtv) return 0;
if (nmtv->hdr.code == TVN_SELCHANGEDA || nmtv->hdr.code == TVN_SELCHANGEDW)
{
if (nmtv->itemOld.lParam)
{
OPT_OBJECT_DATA * dataOld = (OPT_OBJECT_DATA*)nmtv->itemOld.lParam;
if (dataOld->szValue) {
mir_free(dataOld->szValue);
dataOld->szValue = MadeString(hwndDlg);
}
}
if (nmtv->itemNew.lParam)
{
OPT_OBJECT_DATA * data = (OPT_OBJECT_DATA*)nmtv->itemNew.lParam;
char buf[255];
mir_snprintf(buf,SIZEOF(buf),"%s = %s",data->szName, data->szValue);
SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT, 0, (LPARAM)buf);
SetControls(hwndDlg,data->szValue);
EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),TRUE);
EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),object_clipboard != NULL);
}
else
{
SendDlgItemMessageA(hwndDlg,IDC_EDIT1,WM_SETTEXT, 0, (LPARAM)"");
SetControls(hwndDlg,NULL);
EnableWindow(GetDlgItem(hwndDlg,IDC_COPY),FALSE);
EnableWindow(GetDlgItem(hwndDlg,IDC_PASTE),FALSE);
}
}
else if (nmtv->hdr.code == TVN_DELETEITEMA)
{
OPT_OBJECT_DATA * dataOld = (OPT_OBJECT_DATA*)nmtv->itemOld.lParam;
if (dataOld) {
mir_free_and_nil(dataOld->szName);
mir_free_and_nil(dataOld->szPath);
mir_free_and_nil(dataOld->szTempValue);
mir_free_and_nil(dataOld->szValue);
}
}
return 0;
}
case 0:
switch (((LPNMHDR)lParam)->code)
{
case PSN_APPLY:
if ( !glOtherSkinWasLoaded) //store only if skin is same
{
StoreTreeToDB(GetDlgItem(hwndDlg,IDC_OBJECT_TREE),SKIN);
//ReloadSkin
ske_LoadSkinFromDB();
pcli->pfnClcBroadcast( INTM_RELOADOPTIONS, 0, 0);
Sync(CLUIFrames_OnClistResize_mod, 0, 0);
ske_RedrawCompleteWindow();
Sync(CLUIFrames_OnClistResize_mod, 0, 0);
{
HWND hwnd = pcli->hwndContactList;
RECT rc = {0};
GetWindowRect(hwnd, &rc);
Sync(CLUIFrames_OnMoving,hwnd,&rc);
}
return TRUE;
}
else
return TRUE;
}
break;
}
case WM_DESTROY:
mir_free(object_clipboard);
break;
}
return FALSE;
}
int EnableGroup(HWND hwndDlg, HWND first, BOOL bEnable)
{
HWND hwnd = first;
BOOL exit = FALSE;
if ( !hwnd) return 0;
do
{
EnableWindow(hwnd,bEnable);
hwnd = GetWindow(hwnd,GW_HWNDNEXT);
if ( !hwnd || GetWindowLongPtr(hwnd,GWL_STYLE)&WS_GROUP) exit = TRUE;
}
while (!exit);
return 0;
}
int ShowGroup(HWND hwndDlg, HWND first, BOOL bEnable)
{
HWND hwnd = first;
BOOL exit = FALSE;
if ( !hwnd) return 0;
do
{
ShowWindow(hwnd,bEnable?SW_SHOW:SW_HIDE);
hwnd = GetWindow(hwnd,GW_HWNDNEXT);
if ( !hwnd || GetWindowLongPtr(hwnd,GWL_STYLE)&WS_GROUP) exit = TRUE;
}
while (!exit);
return 0;
}
|