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
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
|
/*
Copyright (C) 2008 Ricardo Pescuma Domenecci
This is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this file; see the file license.txt. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "commons.h"
// Prototypes ///////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
#ifdef UNICODE
"Skins (Unicode)",
#else
"Skins",
#endif
PLUGIN_MAKE_VERSION(0,0,0,5),
"Skins",
"Ricardo Pescuma Domenecci",
"",
"© 2008-2010 Ricardo Pescuma Domenecci",
"http://pescuma.org/miranda/skins",
UNICODE_AWARE,
0, //doesn't replace anything built-in
#ifdef UNICODE
{ 0xde546127, 0x2cdd, 0x48ca, { 0x8a, 0xe5, 0x36, 0x25, 0xe7, 0x24, 0xf2, 0xda } }
#else
{ 0x2f630a2a, 0xd8f9, 0x4f81, { 0x8a, 0x4e, 0xce, 0x9a, 0x73, 0x5d, 0xf2, 0xe9 } }
#endif
};
HINSTANCE hInst;
PLUGINLINK *pluginLink;
std::vector<HANDLE> hHooks;
std::vector<HANDLE> hServices;
HANDLE hNetlibUser = 0;
HANDLE hSkinsFolder = NULL;
TCHAR skinsFolder[1024];
std::vector<MirandaSkinnedDialog *> dlgs;
LIST_INTERFACE li;
FI_INTERFACE *fei = NULL;
struct MM_INTERFACE mmi;
struct UTF8_INTERFACE utfi;
int ModulesLoaded(WPARAM wParam, LPARAM lParam);
int PreShutdown(WPARAM wParam, LPARAM lParam);
static int Service_GetInterface(WPARAM wParam, LPARAM lParam);
// Functions ////////////////////////////////////////////////////////////////////////////
extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst = hinstDLL;
return TRUE;
}
extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
{
pluginInfo.cbSize = sizeof(PLUGININFO);
return (PLUGININFO*) &pluginInfo;
}
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
pluginInfo.cbSize = sizeof(PLUGININFOEX);
return &pluginInfo;
}
static const MUUID interfaces[] = { MIID_SKINS, MIID_LAST };
extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
{
return interfaces;
}
extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
pluginLink = link;
CHECK_VERSION("Skins");
// TODO Assert results here
mir_getMMI(&mmi);
mir_getUTFI(&utfi);
mir_getLI(&li);
hHooks.push_back( HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded) );
hHooks.push_back( HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown) );
NETLIBUSER nl_user = {0};
nl_user.cbSize = sizeof(nl_user);
nl_user.szSettingsModule = MODULE_NAME;
nl_user.flags = NUF_NOOPTIONS;
nl_user.szDescriptiveName = Translate("Skins");
hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
TCHAR mirandaFolder[1024];
GetModuleFileName(GetModuleHandle(NULL), mirandaFolder, MAX_REGS(mirandaFolder));
TCHAR *p = _tcsrchr(mirandaFolder, _T('\\'));
if (p != NULL)
*p = _T('\0');
// Folders plugin support
if (ServiceExists(MS_FOLDERS_REGISTER_PATH))
{
hSkinsFolder = FoldersRegisterCustomPathT("Skins", "Skins", _T(MIRANDA_PATH) _T("\\Skins"));
FoldersGetCustomPathT(hSkinsFolder, skinsFolder, MAX_REGS(skinsFolder), _T("."));
}
else
{
mir_sntprintf(skinsFolder, MAX_REGS(skinsFolder), _T("%s\\Skins"), mirandaFolder);
}
InitOptions();
hServices.push_back( CreateServiceFunction(MS_SKINS_GETINTERFACE, Service_GetInterface) );
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
}
// Called when all the modules are loaded
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
// add our modules to the KnownModules list
CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0);
// updater plugin support
if(ServiceExists(MS_UPDATE_REGISTER))
{
Update upd = {0};
char szCurrentVersion[30];
upd.cbSize = sizeof(upd);
upd.szComponentName = pluginInfo.shortName;
upd.szUpdateURL = UPDATER_AUTOREGISTER;
upd.szBetaVersionURL = "http://pescuma.googlecode.com/svn/trunk/Miranda/Plugins/skins/Docs/skins_version.txt";
upd.szBetaChangelogURL = "http://pescuma.googlecode.com/svn/trunk/Miranda/Plugins/skins/Docs/skins_changelog.txt";
upd.pbBetaVersionPrefix = (BYTE *)"Skins ";
upd.cpbBetaVersionPrefix = strlen((char *)upd.pbBetaVersionPrefix);
#ifdef UNICODE
upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/skinsW.%VERSION%.zip";
#else
upd.szBetaUpdateURL = "http://pescuma.googlecode.com/files/skins.%VERSION%.zip";
#endif
upd.pbVersion = (BYTE *)CreateVersionStringPlugin((PLUGININFO*) &pluginInfo, szCurrentVersion);
upd.cpbVersion = strlen((char *)upd.pbVersion);
CallService(MS_UPDATE_REGISTER, 0, (LPARAM)&upd);
}
return 0;
}
int PreShutdown(WPARAM wParam, LPARAM lParam)
{
unsigned int i;
for(i = 0; i < hServices.size(); i++)
DestroyServiceFunction(hServices[i]);
hServices.clear();
for(i = 0; i < hHooks.size(); i++)
UnhookEvent(hHooks[i]);
hHooks.clear();
DeInitOptions();
return 0;
}
BOOL FileExists(const char *filename)
{
DWORD attrib = GetFileAttributesA(filename);
if (attrib == 0xFFFFFFFF || (attrib & FILE_ATTRIBUTE_DIRECTORY))
return FALSE;
return TRUE;
}
#ifdef UNICODE
BOOL FileExists(const WCHAR *filename)
{
DWORD attrib = GetFileAttributesW(filename);
if (attrib == 0xFFFFFFFF || (attrib & FILE_ATTRIBUTE_DIRECTORY))
return FALSE;
return TRUE;
}
#endif
BOOL DirExists(const char *filename)
{
DWORD attrib = GetFileAttributesA(filename);
if (attrib == 0xFFFFFFFF || !(attrib & FILE_ATTRIBUTE_DIRECTORY))
return FALSE;
return TRUE;
}
#ifdef UNICODE
BOOL DirExists(const WCHAR *filename)
{
DWORD attrib = GetFileAttributesW(filename);
if (attrib == 0xFFFFFFFF || !(attrib & FILE_ATTRIBUTE_DIRECTORY))
return FALSE;
return TRUE;
}
#endif
BOOL CreatePath(const char *path)
{
char folder[1024];
strncpy(folder, path, MAX_REGS(folder));
folder[MAX_REGS(folder)-1] = '\0';
char *p = folder;
if (p[0] && p[1] == ':' && p[2] == '\\') p += 3; // skip drive letter
SetLastError(ERROR_SUCCESS);
while(p = strchr(p, '\\'))
{
*p = '\0';
CreateDirectoryA(folder, 0);
*p = '\\';
p++;
}
CreateDirectoryA(folder, 0);
DWORD lerr = GetLastError();
return (lerr == ERROR_SUCCESS || lerr == ERROR_ALREADY_EXISTS);
}
void log(const char *fmt, ...)
{
va_list va;
char text[1024];
va_start(va, fmt);
mir_vsnprintf(text, sizeof(text), fmt, va);
va_end(va);
CallService(MS_NETLIB_LOG, (WPARAM) NULL, (LPARAM) text);
}
MirandaSkinnedDialog *GetDialog(const char *name)
{
_ASSERT(name != NULL);
for(unsigned int i = 0; i < dlgs.size(); i++)
{
MirandaSkinnedDialog *dlg = dlgs[i];
if (strcmp(name, dlg->getName()) == 0)
return dlg;
}
return NULL;
}
void getSkinnedDialogFilename(std::tstring &ret, const TCHAR *skin, const char *dialogName)
{
ret = skinsFolder;
ret += _T("\\");
ret += skin;
ret += _T("\\");
ret += CharToTchar(dialogName);
ret += _T(".");
ret += _T(SKIN_EXTENSION);
}
void getAvaiableSkins(std::vector<std::tstring> &skins, MirandaSkinnedDialog *dlg)
{
TCHAR file[1024];
mir_sntprintf(file, MAX_REGS(file), _T("%s\\*"), skinsFolder);
WIN32_FIND_DATA ffd = {0};
HANDLE hFFD = FindFirstFile(file, &ffd);
if (hFFD == INVALID_HANDLE_VALUE)
return;
do
{
if (lstrcmp(ffd.cFileName, _T(".")) == 0 || lstrcmp(ffd.cFileName, _T("..")) == 0)
continue;
mir_sntprintf(file, MAX_REGS(file), _T("%s\\%s"), skinsFolder, ffd.cFileName);
if (!DirExists(file))
continue;
if (dlg != NULL)
{
std::tstring filename;
getSkinnedDialogFilename(filename, ffd.cFileName, dlg->getName());
if (!FileExists(filename.c_str()))
continue;
}
skins.push_back(std::tstring(ffd.cFileName));
}
while(FindNextFile(hFFD, &ffd));
FindClose(hFFD);
}
void OnError(void *param, const TCHAR *err)
{
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) param;
std::tstring title;
title = CharToTchar(dlg->getName());
title += _T("- Error executing skin");
MessageBox(NULL, err, title.c_str(), MB_OK | MB_ICONERROR);
}
SKINNED_DIALOG Interface_RegisterDialog(const char *name, const char *description, const char *module)
{
if (name == NULL || name[0] == 0 || module == NULL || module[0] == 0)
return NULL;
if (GetDialog(name) != NULL)
return NULL;
// Check if default skin exists
std::tstring filename;
filename = skinsFolder;
filename += _T("\\");
filename += _T(DEFAULT_SKIN_NAME);
filename += _T("\\");
filename += Utf8ToTchar(name);
filename += _T(".");
filename += _T(SKIN_EXTENSION);
if (!FileExists(filename.c_str()))
return NULL;
MirandaSkinnedDialog *dlg = new MirandaSkinnedDialog(name, description, module);
dlg->setErrorCallback(OnError, dlg);
dlgs.push_back(dlg);
return (SKINNED_DIALOG) dlg;
}
void Interface_DeleteDialog(SKINNED_DIALOG aDlg)
{
if (aDlg == NULL)
return;
MirandaSkinnedDialog * dlg = (MirandaSkinnedDialog *) aDlg;
for(std::vector<MirandaSkinnedDialog*>::iterator it = dlgs.begin(); it != dlgs.end(); it++)
{
if (*it == dlg)
{
dlgs.erase(it);
break;
}
}
delete dlg;
}
void Interface_SetSkinChangedCallback(SKINNED_DIALOG aDlg, SkinOptionsChangedCallback cb, void *param)
{
if (aDlg == NULL)
return;
MirandaSkinnedDialog * dlg = (MirandaSkinnedDialog *) aDlg;
dlg->setOnSkinChangedCallback((MirandaSkinnedCallback) cb, param);
}
void Interface_FinishedConfiguring(SKINNED_DIALOG aDlg)
{
if (aDlg == NULL)
return;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
dlg->finishedConfiguring();
}
SKINNED_FIELD Interface_AddTextField(SKINNED_DIALOG aDlg, const char *name, const char *description)
{
if (aDlg == NULL || name == NULL || name[0] == 0)
return NULL;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
MirandaTextField *field = new MirandaTextField(dlg, name, description);
if (!dlg->addField(field))
{
delete field;
return NULL;
}
return (SKINNED_FIELD) field;
}
SKINNED_FIELD Interface_AddIconField(SKINNED_DIALOG aDlg, const char *name, const char *description)
{
if (aDlg == NULL || name == NULL || name[0] == 0)
return NULL;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
MirandaIconField *field = new MirandaIconField(dlg, name, description);
if (!dlg->addField(field))
{
delete field;
return NULL;
}
return (SKINNED_FIELD) field;
}
SKINNED_FIELD Interface_AddImageField(SKINNED_DIALOG aDlg, const char *name, const char *description)
{
if (aDlg == NULL || name == NULL || name[0] == 0)
return NULL;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
MirandaImageField *field = new MirandaImageField(dlg, name, description);
if (!dlg->addField(field))
{
delete field;
return NULL;
}
return (SKINNED_FIELD) field;
}
SKINNED_FIELD Interface_GetField(SKINNED_DIALOG aDlg, const char *name)
{
if (aDlg == NULL || name == NULL || name[0] == 0)
return NULL;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
return (SKINNED_FIELD) dlg->getField(name);
}
void Interface_SetDialogSize(SKINNED_DIALOG aDlg, int width, int height)
{
if (aDlg == NULL)
return;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
dlg->setSize(Size(width, height));
}
void Interface_SetInfoInt(SKINNED_DIALOG aDlg, const char *name, int value)
{
if (aDlg == NULL || name == NULL)
return;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
dlg->getInfo()->set(name, value);
}
void Interface_SetInfoDouble(SKINNED_DIALOG aDlg, const char *name, double value)
{
if (aDlg == NULL || name == NULL)
return;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
dlg->getInfo()->set(name, value);
}
void Interface_SetInfoBool(SKINNED_DIALOG aDlg, const char *name, BOOL value)
{
if (aDlg == NULL || name == NULL)
return;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
dlg->getInfo()->set(name, value);
}
void Interface_SetInfoString(SKINNED_DIALOG aDlg, const char *name, const TCHAR *value)
{
if (aDlg == NULL || name == NULL)
return;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
dlg->getInfo()->set(name, value);
}
void Interface_RemoveInfo(SKINNED_DIALOG aDlg, const char *name)
{
if (aDlg == NULL || name == NULL)
return;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
dlg->getInfo()->remove(name);
}
void Interface_SetEnabled(SKINNED_FIELD aField, BOOL enabled)
{
if (aField == NULL)
return;
Field *field = (Field *) aField;
field->setEnabled(enabled != 0);
}
void Interface_SetToolTipA(SKINNED_FIELD aField, const char *tooltip)
{
if (aField == NULL)
return;
Field *field = (Field *) aField;
field->setToolTip(CharToTchar(tooltip));
}
void Interface_SetToolTipW(SKINNED_FIELD aField, const WCHAR *tooltip)
{
if (aField == NULL)
return;
Field *field = (Field *) aField;
field->setToolTip(WcharToTchar(tooltip));
}
void Interface_SetTextA(SKINNED_FIELD aField, const char *text)
{
if (aField == NULL)
return;
Field *field = (Field *) aField;
switch(field->getType())
{
case SIMPLE_TEXT:
((TextField *) field)->setText(CharToTchar(text));
break;
case CONTROL_LABEL:
case CONTROL_BUTTON:
case CONTROL_EDIT:
((ControlField *) field)->setText(CharToTchar(text));
break;
}
}
void Interface_SetTextW(SKINNED_FIELD aField, const WCHAR *text)
{
if (aField == NULL)
return;
Field *field = (Field *) aField;
switch(field->getType())
{
case SIMPLE_TEXT:
((TextField *) field)->setText(WcharToTchar(text));
break;
case CONTROL_LABEL:
case CONTROL_BUTTON:
case CONTROL_EDIT:
((ControlField *) field)->setText(WcharToTchar(text));
break;
}
}
void Interface_SetIcon(SKINNED_FIELD aField, HICON hIcon)
{
if (aField == NULL)
return;
Field *field = (Field *) aField;
switch(field->getType())
{
case SIMPLE_ICON:
((IconField *) field)->setIcon(hIcon);
break;
}
}
void Interface_SetImage(SKINNED_FIELD aField, HBITMAP hBmp)
{
if (aField == NULL)
return;
Field *field = (Field *) aField;
switch(field->getType())
{
case SIMPLE_IMAGE:
((ImageField *) field)->setImage(hBmp);
break;
}
}
SKINNED_DIALOG_STATE Interface_Run(SKINNED_DIALOG aDlg)
{
if (aDlg == NULL)
return NULL;
MirandaSkinnedDialog *dlg = (MirandaSkinnedDialog *) aDlg;
return (SKINNED_DIALOG_STATE) dlg->getState();
}
/*
void Interface_DeleteDialogState(SKINNED_DIALOG_STATE aDlg)
{
if (aDlg == NULL)
return;
DialogState * dlg = (DialogState *) aDlg;
delete dlg;
}
*/
SKINNED_FIELD_STATE Interface_GetFieldState(SKINNED_DIALOG_STATE aDlg, const char *name)
{
if (aDlg == NULL || name == NULL || name[0] == 0)
return NULL;
DialogState *dlg = (DialogState *) aDlg;
return (SKINNED_FIELD_STATE) dlg->getField(name);
}
RECT Interface_GetDialogBorders(SKINNED_DIALOG_STATE aDlg)
{
RECT ret = {0};
if (aDlg == NULL)
return ret;
DialogState *state = (DialogState *) aDlg;
BorderState *borders = state->getBorders();
ret.left = borders->getLeft();
ret.top = borders->getTop();
ret.right = borders->getRight();
ret.bottom = borders->getBottom();
return ret;
}
RECT Interface_GetRect(SKINNED_FIELD_STATE field)
{
if (field == NULL)
{
RECT ret = {0};
return ret;
}
FieldState *fieldState = (FieldState *) field;
return fieldState->getRect();
}
RECT Interface_GetInsideRect(SKINNED_FIELD_STATE field)
{
if (field == NULL)
{
RECT ret = {0};
return ret;
}
FieldState *fieldState = (FieldState *) field;
return fieldState->getInsideRect();
}
RECT Interface_GetRawRect(SKINNED_FIELD_STATE field)
{
if (field == NULL)
{
RECT ret = {0};
return ret;
}
FieldState *fieldState = (FieldState *) field;
return fieldState->getRect(true);
}
RECT Interface_GetRawInsideRect(SKINNED_FIELD_STATE field)
{
if (field == NULL)
{
RECT ret = {0};
return ret;
}
FieldState *fieldState = (FieldState *) field;
return fieldState->getInsideRect(true);
}
RECT Interface_GetBorders(SKINNED_FIELD_STATE field)
{
RECT ret = {0};
if (field == NULL)
return ret;
FieldState *fieldState = (FieldState *) field;
BorderState *borders = fieldState->getBorders();
ret.left = borders->getLeft();
ret.top = borders->getTop();
ret.right = borders->getRight();
ret.bottom = borders->getBottom();
return ret;
}
BOOL Interface_IsVisible(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return FALSE;
FieldState *fieldState = (FieldState *) field;
return fieldState->isVisible();
}
char * Interface_GetToolTipA(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return NULL;
FieldState *fieldState = (FieldState *) field;
return TcharToChar(fieldState->getToolTip()).detach();
}
WCHAR * Interface_GetToolTipW(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return NULL;
FieldState *fieldState = (FieldState *) field;
return TcharToWchar(fieldState->getToolTip()).detach();
}
char * Interface_GetTextA(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return NULL;
FieldState *fieldState = (FieldState *) field;
switch(fieldState->getField()->getType())
{
case SIMPLE_TEXT:
return TcharToChar(((TextFieldState *) fieldState)->getText()).detach();
case CONTROL_LABEL:
case CONTROL_BUTTON:
case CONTROL_EDIT:
return TcharToChar(((ControlFieldState *) field)->getText()).detach();
}
return NULL;
}
WCHAR * Interface_GetTextW(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return NULL;
FieldState *fieldState = (FieldState *) field;
switch(fieldState->getField()->getType())
{
case SIMPLE_TEXT:
return TcharToWchar(((TextFieldState *) fieldState)->getText()).detach();
case CONTROL_LABEL:
case CONTROL_BUTTON:
case CONTROL_EDIT:
return TcharToWchar(((ControlFieldState *) field)->getText()).detach();
}
return NULL;
}
HFONT Interface_GetFont(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return NULL;
FieldState *fieldState = (FieldState *) field;
switch(fieldState->getField()->getType())
{
case SIMPLE_TEXT:
return ((TextFieldState *) fieldState)->getFont()->getHFONT();
case CONTROL_LABEL:
case CONTROL_BUTTON:
case CONTROL_EDIT:
return ((ControlFieldState *) fieldState)->getFont()->getHFONT();
}
return NULL;
}
COLORREF Interface_GetFontColor(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return RGB(0,0,0);
FieldState *fieldState = (FieldState *) field;
switch(fieldState->getField()->getType())
{
case SIMPLE_TEXT:
return ((TextFieldState *) fieldState)->getFont()->getColor();
case CONTROL_LABEL:
case CONTROL_BUTTON:
case CONTROL_EDIT:
return ((ControlFieldState *) fieldState)->getFont()->getColor();
}
return RGB(0,0,0);
}
int Interface_GetHorizontalAlign(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return SKN_HALIGN_LEFT;
FieldState *fieldState = (FieldState *) field;
return fieldState->getHAlign();
}
int Interface_GetVerticalAlign(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return SKN_VALIGN_TOP;
FieldState *fieldState = (FieldState *) field;
return fieldState->getVAlign();
}
HICON Interface_GetIcon(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return NULL;
FieldState *fieldState = (FieldState *) field;
switch(fieldState->getField()->getType())
{
case SIMPLE_ICON:
return ((IconFieldState *) fieldState)->getIcon();
}
return NULL;
}
HBITMAP Interface_GetImage(SKINNED_FIELD_STATE field)
{
if (field == NULL)
return NULL;
FieldState *fieldState = (FieldState *) field;
switch(fieldState->getField()->getType())
{
case SIMPLE_IMAGE:
return ((ImageFieldState *) fieldState)->getImage();
}
return NULL;
}
static int Service_GetInterface(WPARAM wParam, LPARAM lParam)
{
SKIN_INTERFACE *mski = (SKIN_INTERFACE *) lParam;
if (mski == NULL)
return -1;
if (mski->cbSize < sizeof(SKIN_INTERFACE))
return -2;
mski->RegisterDialog = &Interface_RegisterDialog;
mski->DeleteDialog = &Interface_DeleteDialog;
mski->SetSkinChangedCallback = &Interface_SetSkinChangedCallback;
mski->FinishedConfiguring = &Interface_FinishedConfiguring;
mski->AddTextField = &Interface_AddTextField;
mski->AddIconField = &Interface_AddIconField;
mski->AddImageField = &Interface_AddImageField;
mski->GetField = &Interface_GetField;
mski->SetDialogSize = &Interface_SetDialogSize;
mski->SetInfoInt = &Interface_SetInfoInt;
mski->SetInfoDouble = &Interface_SetInfoDouble;
mski->SetInfoBool = &Interface_SetInfoBool;
mski->SetInfoString = &Interface_SetInfoString;
mski->RemoveInfo = &Interface_RemoveInfo;
mski->SetEnabled = &Interface_SetEnabled;
mski->SetToolTipA = &Interface_SetToolTipA;
mski->SetToolTipW = &Interface_SetToolTipW;
mski->SetTextA = &Interface_SetTextA;
mski->SetTextW = &Interface_SetTextW;
mski->SetIcon = &Interface_SetIcon;
mski->SetImage = &Interface_SetImage;
mski->Run = &Interface_Run;
mski->GetFieldState = &Interface_GetFieldState;
mski->GetDialogBorders = &Interface_GetDialogBorders;
mski->GetRect = &Interface_GetRect;
mski->GetInsideRect = &Interface_GetInsideRect;
mski->GetRawRect = &Interface_GetRawRect;
mski->GetRawInsideRect = &Interface_GetRawInsideRect;
mski->GetBorders = &Interface_GetBorders;
mski->IsVisible = &Interface_IsVisible;
mski->GetToolTipA = &Interface_GetToolTipA;
mski->GetToolTipW = &Interface_GetToolTipW;
mski->GetHorizontalAlign = &Interface_GetHorizontalAlign;
mski->GetVerticalAlign = &Interface_GetVerticalAlign;
mski->GetTextA = &Interface_GetTextA;
mski->GetTextW = &Interface_GetTextW;
mski->GetFont = &Interface_GetFont;
mski->GetFontColor = &Interface_GetFontColor;
mski->GetIcon = &Interface_GetIcon;
mski->GetImage = &Interface_GetImage;
return 0;
}
|