2
/* ========================== Module _Icn =========================== */
9
#include "pymactoolbox.h"
11
/* Macro to test whether a weak-loaded CFM function exists */
12
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
13
PyErr_SetString(PyExc_NotImplementedError, \
14
"Not available in this shared library/OS version"); \
19
#include <Carbon/Carbon.h>
22
static PyObject *Icn_Error;
24
static PyObject *Icn_GetCIcon(PyObject *_self, PyObject *_args)
26
PyObject *_res = NULL;
30
PyMac_PRECHECK(GetCIcon);
32
if (!PyArg_ParseTuple(_args, "h",
35
_rv = GetCIcon(iconID);
36
_res = Py_BuildValue("O&",
41
static PyObject *Icn_PlotCIcon(PyObject *_self, PyObject *_args)
43
PyObject *_res = NULL;
47
PyMac_PRECHECK(PlotCIcon);
49
if (!PyArg_ParseTuple(_args, "O&O&",
50
PyMac_GetRect, &theRect,
51
ResObj_Convert, &theIcon))
60
static PyObject *Icn_DisposeCIcon(PyObject *_self, PyObject *_args)
62
PyObject *_res = NULL;
65
PyMac_PRECHECK(DisposeCIcon);
67
if (!PyArg_ParseTuple(_args, "O&",
68
ResObj_Convert, &theIcon))
70
DisposeCIcon(theIcon);
76
static PyObject *Icn_GetIcon(PyObject *_self, PyObject *_args)
78
PyObject *_res = NULL;
82
PyMac_PRECHECK(GetIcon);
84
if (!PyArg_ParseTuple(_args, "h",
87
_rv = GetIcon(iconID);
88
_res = Py_BuildValue("O&",
93
static PyObject *Icn_PlotIcon(PyObject *_self, PyObject *_args)
95
PyObject *_res = NULL;
99
PyMac_PRECHECK(PlotIcon);
101
if (!PyArg_ParseTuple(_args, "O&O&",
102
PyMac_GetRect, &theRect,
103
ResObj_Convert, &theIcon))
112
static PyObject *Icn_PlotIconID(PyObject *_self, PyObject *_args)
114
PyObject *_res = NULL;
117
IconAlignmentType align;
118
IconTransformType transform;
121
PyMac_PRECHECK(PlotIconID);
123
if (!PyArg_ParseTuple(_args, "O&hhh",
124
PyMac_GetRect, &theRect,
129
_err = PlotIconID(&theRect,
133
if (_err != noErr) return PyMac_Error(_err);
139
static PyObject *Icn_NewIconSuite(PyObject *_self, PyObject *_args)
141
PyObject *_res = NULL;
143
IconSuiteRef theIconSuite;
145
PyMac_PRECHECK(NewIconSuite);
147
if (!PyArg_ParseTuple(_args, ""))
149
_err = NewIconSuite(&theIconSuite);
150
if (_err != noErr) return PyMac_Error(_err);
151
_res = Py_BuildValue("O&",
152
ResObj_New, theIconSuite);
156
static PyObject *Icn_AddIconToSuite(PyObject *_self, PyObject *_args)
158
PyObject *_res = NULL;
161
IconSuiteRef theSuite;
163
#ifndef AddIconToSuite
164
PyMac_PRECHECK(AddIconToSuite);
166
if (!PyArg_ParseTuple(_args, "O&O&O&",
167
ResObj_Convert, &theIconData,
168
ResObj_Convert, &theSuite,
169
PyMac_GetOSType, &theType))
171
_err = AddIconToSuite(theIconData,
174
if (_err != noErr) return PyMac_Error(_err);
180
static PyObject *Icn_GetIconFromSuite(PyObject *_self, PyObject *_args)
182
PyObject *_res = NULL;
185
IconSuiteRef theSuite;
187
#ifndef GetIconFromSuite
188
PyMac_PRECHECK(GetIconFromSuite);
190
if (!PyArg_ParseTuple(_args, "O&O&",
191
ResObj_Convert, &theSuite,
192
PyMac_GetOSType, &theType))
194
_err = GetIconFromSuite(&theIconData,
197
if (_err != noErr) return PyMac_Error(_err);
198
_res = Py_BuildValue("O&",
199
ResObj_New, theIconData);
203
static PyObject *Icn_GetIconSuite(PyObject *_self, PyObject *_args)
205
PyObject *_res = NULL;
207
IconSuiteRef theIconSuite;
209
IconSelectorValue selector;
211
PyMac_PRECHECK(GetIconSuite);
213
if (!PyArg_ParseTuple(_args, "hl",
217
_err = GetIconSuite(&theIconSuite,
220
if (_err != noErr) return PyMac_Error(_err);
221
_res = Py_BuildValue("O&",
222
ResObj_New, theIconSuite);
226
static PyObject *Icn_DisposeIconSuite(PyObject *_self, PyObject *_args)
228
PyObject *_res = NULL;
230
IconSuiteRef theIconSuite;
232
#ifndef DisposeIconSuite
233
PyMac_PRECHECK(DisposeIconSuite);
235
if (!PyArg_ParseTuple(_args, "O&b",
236
ResObj_Convert, &theIconSuite,
239
_err = DisposeIconSuite(theIconSuite,
241
if (_err != noErr) return PyMac_Error(_err);
247
static PyObject *Icn_PlotIconSuite(PyObject *_self, PyObject *_args)
249
PyObject *_res = NULL;
252
IconAlignmentType align;
253
IconTransformType transform;
254
IconSuiteRef theIconSuite;
255
#ifndef PlotIconSuite
256
PyMac_PRECHECK(PlotIconSuite);
258
if (!PyArg_ParseTuple(_args, "O&hhO&",
259
PyMac_GetRect, &theRect,
262
ResObj_Convert, &theIconSuite))
264
_err = PlotIconSuite(&theRect,
268
if (_err != noErr) return PyMac_Error(_err);
274
static PyObject *Icn_LoadIconCache(PyObject *_self, PyObject *_args)
276
PyObject *_res = NULL;
279
IconAlignmentType align;
280
IconTransformType transform;
281
IconCacheRef theIconCache;
282
#ifndef LoadIconCache
283
PyMac_PRECHECK(LoadIconCache);
285
if (!PyArg_ParseTuple(_args, "O&hhO&",
286
PyMac_GetRect, &theRect,
289
ResObj_Convert, &theIconCache))
291
_err = LoadIconCache(&theRect,
295
if (_err != noErr) return PyMac_Error(_err);
301
static PyObject *Icn_GetLabel(PyObject *_self, PyObject *_args)
303
PyObject *_res = NULL;
309
PyMac_PRECHECK(GetLabel);
311
if (!PyArg_ParseTuple(_args, "hO&",
313
PyMac_GetStr255, labelString))
315
_err = GetLabel(labelNumber,
318
if (_err != noErr) return PyMac_Error(_err);
319
_res = Py_BuildValue("O&",
320
QdRGB_New, &labelColor);
324
static PyObject *Icn_PtInIconID(PyObject *_self, PyObject *_args)
326
PyObject *_res = NULL;
330
IconAlignmentType align;
333
PyMac_PRECHECK(PtInIconID);
335
if (!PyArg_ParseTuple(_args, "O&O&hh",
336
PyMac_GetPoint, &testPt,
337
PyMac_GetRect, &iconRect,
341
_rv = PtInIconID(testPt,
345
_res = Py_BuildValue("b",
350
static PyObject *Icn_PtInIconSuite(PyObject *_self, PyObject *_args)
352
PyObject *_res = NULL;
356
IconAlignmentType align;
357
IconSuiteRef theIconSuite;
358
#ifndef PtInIconSuite
359
PyMac_PRECHECK(PtInIconSuite);
361
if (!PyArg_ParseTuple(_args, "O&O&hO&",
362
PyMac_GetPoint, &testPt,
363
PyMac_GetRect, &iconRect,
365
ResObj_Convert, &theIconSuite))
367
_rv = PtInIconSuite(testPt,
371
_res = Py_BuildValue("b",
376
static PyObject *Icn_RectInIconID(PyObject *_self, PyObject *_args)
378
PyObject *_res = NULL;
382
IconAlignmentType align;
385
PyMac_PRECHECK(RectInIconID);
387
if (!PyArg_ParseTuple(_args, "O&O&hh",
388
PyMac_GetRect, &testRect,
389
PyMac_GetRect, &iconRect,
393
_rv = RectInIconID(&testRect,
397
_res = Py_BuildValue("b",
402
static PyObject *Icn_RectInIconSuite(PyObject *_self, PyObject *_args)
404
PyObject *_res = NULL;
408
IconAlignmentType align;
409
IconSuiteRef theIconSuite;
410
#ifndef RectInIconSuite
411
PyMac_PRECHECK(RectInIconSuite);
413
if (!PyArg_ParseTuple(_args, "O&O&hO&",
414
PyMac_GetRect, &testRect,
415
PyMac_GetRect, &iconRect,
417
ResObj_Convert, &theIconSuite))
419
_rv = RectInIconSuite(&testRect,
423
_res = Py_BuildValue("b",
428
static PyObject *Icn_IconIDToRgn(PyObject *_self, PyObject *_args)
430
PyObject *_res = NULL;
434
IconAlignmentType align;
437
PyMac_PRECHECK(IconIDToRgn);
439
if (!PyArg_ParseTuple(_args, "O&O&hh",
440
ResObj_Convert, &theRgn,
441
PyMac_GetRect, &iconRect,
445
_err = IconIDToRgn(theRgn,
449
if (_err != noErr) return PyMac_Error(_err);
455
static PyObject *Icn_IconSuiteToRgn(PyObject *_self, PyObject *_args)
457
PyObject *_res = NULL;
461
IconAlignmentType align;
462
IconSuiteRef theIconSuite;
463
#ifndef IconSuiteToRgn
464
PyMac_PRECHECK(IconSuiteToRgn);
466
if (!PyArg_ParseTuple(_args, "O&O&hO&",
467
ResObj_Convert, &theRgn,
468
PyMac_GetRect, &iconRect,
470
ResObj_Convert, &theIconSuite))
472
_err = IconSuiteToRgn(theRgn,
476
if (_err != noErr) return PyMac_Error(_err);
482
static PyObject *Icn_SetSuiteLabel(PyObject *_self, PyObject *_args)
484
PyObject *_res = NULL;
486
IconSuiteRef theSuite;
488
#ifndef SetSuiteLabel
489
PyMac_PRECHECK(SetSuiteLabel);
491
if (!PyArg_ParseTuple(_args, "O&h",
492
ResObj_Convert, &theSuite,
495
_err = SetSuiteLabel(theSuite,
497
if (_err != noErr) return PyMac_Error(_err);
503
static PyObject *Icn_GetSuiteLabel(PyObject *_self, PyObject *_args)
505
PyObject *_res = NULL;
507
IconSuiteRef theSuite;
508
#ifndef GetSuiteLabel
509
PyMac_PRECHECK(GetSuiteLabel);
511
if (!PyArg_ParseTuple(_args, "O&",
512
ResObj_Convert, &theSuite))
514
_rv = GetSuiteLabel(theSuite);
515
_res = Py_BuildValue("h",
520
static PyObject *Icn_PlotIconHandle(PyObject *_self, PyObject *_args)
522
PyObject *_res = NULL;
525
IconAlignmentType align;
526
IconTransformType transform;
528
#ifndef PlotIconHandle
529
PyMac_PRECHECK(PlotIconHandle);
531
if (!PyArg_ParseTuple(_args, "O&hhO&",
532
PyMac_GetRect, &theRect,
535
ResObj_Convert, &theIcon))
537
_err = PlotIconHandle(&theRect,
541
if (_err != noErr) return PyMac_Error(_err);
547
static PyObject *Icn_PlotSICNHandle(PyObject *_self, PyObject *_args)
549
PyObject *_res = NULL;
552
IconAlignmentType align;
553
IconTransformType transform;
555
#ifndef PlotSICNHandle
556
PyMac_PRECHECK(PlotSICNHandle);
558
if (!PyArg_ParseTuple(_args, "O&hhO&",
559
PyMac_GetRect, &theRect,
562
ResObj_Convert, &theSICN))
564
_err = PlotSICNHandle(&theRect,
568
if (_err != noErr) return PyMac_Error(_err);
574
static PyObject *Icn_PlotCIconHandle(PyObject *_self, PyObject *_args)
576
PyObject *_res = NULL;
579
IconAlignmentType align;
580
IconTransformType transform;
581
CIconHandle theCIcon;
582
#ifndef PlotCIconHandle
583
PyMac_PRECHECK(PlotCIconHandle);
585
if (!PyArg_ParseTuple(_args, "O&hhO&",
586
PyMac_GetRect, &theRect,
589
ResObj_Convert, &theCIcon))
591
_err = PlotCIconHandle(&theRect,
595
if (_err != noErr) return PyMac_Error(_err);
601
static PyObject *Icn_IconRefToIconFamily(PyObject *_self, PyObject *_args)
603
PyObject *_res = NULL;
606
IconSelectorValue whichIcons;
607
IconFamilyHandle iconFamily;
608
#ifndef IconRefToIconFamily
609
PyMac_PRECHECK(IconRefToIconFamily);
611
if (!PyArg_ParseTuple(_args, "O&l",
612
ResObj_Convert, &theIconRef,
615
_err = IconRefToIconFamily(theIconRef,
618
if (_err != noErr) return PyMac_Error(_err);
619
_res = Py_BuildValue("O&",
620
ResObj_New, iconFamily);
624
static PyObject *Icn_IconFamilyToIconSuite(PyObject *_self, PyObject *_args)
626
PyObject *_res = NULL;
628
IconFamilyHandle iconFamily;
629
IconSelectorValue whichIcons;
630
IconSuiteRef iconSuite;
631
#ifndef IconFamilyToIconSuite
632
PyMac_PRECHECK(IconFamilyToIconSuite);
634
if (!PyArg_ParseTuple(_args, "O&l",
635
ResObj_Convert, &iconFamily,
638
_err = IconFamilyToIconSuite(iconFamily,
641
if (_err != noErr) return PyMac_Error(_err);
642
_res = Py_BuildValue("O&",
643
ResObj_New, iconSuite);
647
static PyObject *Icn_IconSuiteToIconFamily(PyObject *_self, PyObject *_args)
649
PyObject *_res = NULL;
651
IconSuiteRef iconSuite;
652
IconSelectorValue whichIcons;
653
IconFamilyHandle iconFamily;
654
#ifndef IconSuiteToIconFamily
655
PyMac_PRECHECK(IconSuiteToIconFamily);
657
if (!PyArg_ParseTuple(_args, "O&l",
658
ResObj_Convert, &iconSuite,
661
_err = IconSuiteToIconFamily(iconSuite,
664
if (_err != noErr) return PyMac_Error(_err);
665
_res = Py_BuildValue("O&",
666
ResObj_New, iconFamily);
670
static PyObject *Icn_SetIconFamilyData(PyObject *_self, PyObject *_args)
672
PyObject *_res = NULL;
674
IconFamilyHandle iconFamily;
677
#ifndef SetIconFamilyData
678
PyMac_PRECHECK(SetIconFamilyData);
680
if (!PyArg_ParseTuple(_args, "O&O&O&",
681
ResObj_Convert, &iconFamily,
682
PyMac_GetOSType, &iconType,
685
_err = SetIconFamilyData(iconFamily,
688
if (_err != noErr) return PyMac_Error(_err);
694
static PyObject *Icn_GetIconFamilyData(PyObject *_self, PyObject *_args)
696
PyObject *_res = NULL;
698
IconFamilyHandle iconFamily;
701
#ifndef GetIconFamilyData
702
PyMac_PRECHECK(GetIconFamilyData);
704
if (!PyArg_ParseTuple(_args, "O&O&O&",
705
ResObj_Convert, &iconFamily,
706
PyMac_GetOSType, &iconType,
709
_err = GetIconFamilyData(iconFamily,
712
if (_err != noErr) return PyMac_Error(_err);
718
static PyObject *Icn_GetIconRefOwners(PyObject *_self, PyObject *_args)
720
PyObject *_res = NULL;
724
#ifndef GetIconRefOwners
725
PyMac_PRECHECK(GetIconRefOwners);
727
if (!PyArg_ParseTuple(_args, "O&",
728
ResObj_Convert, &theIconRef))
730
_err = GetIconRefOwners(theIconRef,
732
if (_err != noErr) return PyMac_Error(_err);
733
_res = Py_BuildValue("H",
738
static PyObject *Icn_AcquireIconRef(PyObject *_self, PyObject *_args)
740
PyObject *_res = NULL;
743
#ifndef AcquireIconRef
744
PyMac_PRECHECK(AcquireIconRef);
746
if (!PyArg_ParseTuple(_args, "O&",
747
ResObj_Convert, &theIconRef))
749
_err = AcquireIconRef(theIconRef);
750
if (_err != noErr) return PyMac_Error(_err);
756
static PyObject *Icn_ReleaseIconRef(PyObject *_self, PyObject *_args)
758
PyObject *_res = NULL;
761
#ifndef ReleaseIconRef
762
PyMac_PRECHECK(ReleaseIconRef);
764
if (!PyArg_ParseTuple(_args, "O&",
765
ResObj_Convert, &theIconRef))
767
_err = ReleaseIconRef(theIconRef);
768
if (_err != noErr) return PyMac_Error(_err);
774
static PyObject *Icn_GetIconRefFromFile(PyObject *_self, PyObject *_args)
776
PyObject *_res = NULL;
781
#ifndef GetIconRefFromFile
782
PyMac_PRECHECK(GetIconRefFromFile);
784
if (!PyArg_ParseTuple(_args, "O&",
785
PyMac_GetFSSpec, &theFile))
787
_err = GetIconRefFromFile(&theFile,
790
if (_err != noErr) return PyMac_Error(_err);
791
_res = Py_BuildValue("O&h",
792
ResObj_New, theIconRef,
797
static PyObject *Icn_GetIconRef(PyObject *_self, PyObject *_args)
799
PyObject *_res = NULL;
806
PyMac_PRECHECK(GetIconRef);
808
if (!PyArg_ParseTuple(_args, "hO&O&",
810
PyMac_GetOSType, &creator,
811
PyMac_GetOSType, &iconType))
813
_err = GetIconRef(vRefNum,
817
if (_err != noErr) return PyMac_Error(_err);
818
_res = Py_BuildValue("O&",
819
ResObj_New, theIconRef);
823
static PyObject *Icn_GetIconRefFromFolder(PyObject *_self, PyObject *_args)
825
PyObject *_res = NULL;
828
SInt32 parentFolderID;
831
SInt8 accessPrivileges;
833
#ifndef GetIconRefFromFolder
834
PyMac_PRECHECK(GetIconRefFromFolder);
836
if (!PyArg_ParseTuple(_args, "hllbb",
843
_err = GetIconRefFromFolder(vRefNum,
849
if (_err != noErr) return PyMac_Error(_err);
850
_res = Py_BuildValue("O&",
851
ResObj_New, theIconRef);
855
static PyObject *Icn_RegisterIconRefFromIconFamily(PyObject *_self, PyObject *_args)
857
PyObject *_res = NULL;
861
IconFamilyHandle iconFamily;
863
#ifndef RegisterIconRefFromIconFamily
864
PyMac_PRECHECK(RegisterIconRefFromIconFamily);
866
if (!PyArg_ParseTuple(_args, "O&O&O&",
867
PyMac_GetOSType, &creator,
868
PyMac_GetOSType, &iconType,
869
ResObj_Convert, &iconFamily))
871
_err = RegisterIconRefFromIconFamily(creator,
875
if (_err != noErr) return PyMac_Error(_err);
876
_res = Py_BuildValue("O&",
877
ResObj_New, theIconRef);
881
static PyObject *Icn_RegisterIconRefFromResource(PyObject *_self, PyObject *_args)
883
PyObject *_res = NULL;
890
#ifndef RegisterIconRefFromResource
891
PyMac_PRECHECK(RegisterIconRefFromResource);
893
if (!PyArg_ParseTuple(_args, "O&O&O&h",
894
PyMac_GetOSType, &creator,
895
PyMac_GetOSType, &iconType,
896
PyMac_GetFSSpec, &resourceFile,
899
_err = RegisterIconRefFromResource(creator,
904
if (_err != noErr) return PyMac_Error(_err);
905
_res = Py_BuildValue("O&",
906
ResObj_New, theIconRef);
910
static PyObject *Icn_RegisterIconRefFromFSRef(PyObject *_self, PyObject *_args)
912
PyObject *_res = NULL;
918
#ifndef RegisterIconRefFromFSRef
919
PyMac_PRECHECK(RegisterIconRefFromFSRef);
921
if (!PyArg_ParseTuple(_args, "O&O&O&",
922
PyMac_GetOSType, &creator,
923
PyMac_GetOSType, &iconType,
924
PyMac_GetFSRef, &iconFile))
926
_err = RegisterIconRefFromFSRef(creator,
930
if (_err != noErr) return PyMac_Error(_err);
931
_res = Py_BuildValue("O&",
932
ResObj_New, theIconRef);
936
static PyObject *Icn_UnregisterIconRef(PyObject *_self, PyObject *_args)
938
PyObject *_res = NULL;
942
#ifndef UnregisterIconRef
943
PyMac_PRECHECK(UnregisterIconRef);
945
if (!PyArg_ParseTuple(_args, "O&O&",
946
PyMac_GetOSType, &creator,
947
PyMac_GetOSType, &iconType))
949
_err = UnregisterIconRef(creator,
951
if (_err != noErr) return PyMac_Error(_err);
957
static PyObject *Icn_UpdateIconRef(PyObject *_self, PyObject *_args)
959
PyObject *_res = NULL;
962
#ifndef UpdateIconRef
963
PyMac_PRECHECK(UpdateIconRef);
965
if (!PyArg_ParseTuple(_args, "O&",
966
ResObj_Convert, &theIconRef))
968
_err = UpdateIconRef(theIconRef);
969
if (_err != noErr) return PyMac_Error(_err);
975
static PyObject *Icn_OverrideIconRefFromResource(PyObject *_self, PyObject *_args)
977
PyObject *_res = NULL;
982
#ifndef OverrideIconRefFromResource
983
PyMac_PRECHECK(OverrideIconRefFromResource);
985
if (!PyArg_ParseTuple(_args, "O&O&h",
986
ResObj_Convert, &theIconRef,
987
PyMac_GetFSSpec, &resourceFile,
990
_err = OverrideIconRefFromResource(theIconRef,
993
if (_err != noErr) return PyMac_Error(_err);
999
static PyObject *Icn_OverrideIconRef(PyObject *_self, PyObject *_args)
1001
PyObject *_res = NULL;
1005
#ifndef OverrideIconRef
1006
PyMac_PRECHECK(OverrideIconRef);
1008
if (!PyArg_ParseTuple(_args, "O&O&",
1009
ResObj_Convert, &oldIconRef,
1010
ResObj_Convert, &newIconRef))
1012
_err = OverrideIconRef(oldIconRef,
1014
if (_err != noErr) return PyMac_Error(_err);
1020
static PyObject *Icn_RemoveIconRefOverride(PyObject *_self, PyObject *_args)
1022
PyObject *_res = NULL;
1025
#ifndef RemoveIconRefOverride
1026
PyMac_PRECHECK(RemoveIconRefOverride);
1028
if (!PyArg_ParseTuple(_args, "O&",
1029
ResObj_Convert, &theIconRef))
1031
_err = RemoveIconRefOverride(theIconRef);
1032
if (_err != noErr) return PyMac_Error(_err);
1038
static PyObject *Icn_CompositeIconRef(PyObject *_self, PyObject *_args)
1040
PyObject *_res = NULL;
1042
IconRef backgroundIconRef;
1043
IconRef foregroundIconRef;
1044
IconRef compositeIconRef;
1045
#ifndef CompositeIconRef
1046
PyMac_PRECHECK(CompositeIconRef);
1048
if (!PyArg_ParseTuple(_args, "O&O&",
1049
ResObj_Convert, &backgroundIconRef,
1050
ResObj_Convert, &foregroundIconRef))
1052
_err = CompositeIconRef(backgroundIconRef,
1055
if (_err != noErr) return PyMac_Error(_err);
1056
_res = Py_BuildValue("O&",
1057
ResObj_New, compositeIconRef);
1061
static PyObject *Icn_IsIconRefComposite(PyObject *_self, PyObject *_args)
1063
PyObject *_res = NULL;
1065
IconRef compositeIconRef;
1066
IconRef backgroundIconRef;
1067
IconRef foregroundIconRef;
1068
#ifndef IsIconRefComposite
1069
PyMac_PRECHECK(IsIconRefComposite);
1071
if (!PyArg_ParseTuple(_args, "O&",
1072
ResObj_Convert, &compositeIconRef))
1074
_err = IsIconRefComposite(compositeIconRef,
1076
&foregroundIconRef);
1077
if (_err != noErr) return PyMac_Error(_err);
1078
_res = Py_BuildValue("O&O&",
1079
ResObj_New, backgroundIconRef,
1080
ResObj_New, foregroundIconRef);
1084
static PyObject *Icn_IsValidIconRef(PyObject *_self, PyObject *_args)
1086
PyObject *_res = NULL;
1089
#ifndef IsValidIconRef
1090
PyMac_PRECHECK(IsValidIconRef);
1092
if (!PyArg_ParseTuple(_args, "O&",
1093
ResObj_Convert, &theIconRef))
1095
_rv = IsValidIconRef(theIconRef);
1096
_res = Py_BuildValue("b",
1101
static PyObject *Icn_PlotIconRef(PyObject *_self, PyObject *_args)
1103
PyObject *_res = NULL;
1106
IconAlignmentType align;
1107
IconTransformType transform;
1108
IconServicesUsageFlags theIconServicesUsageFlags;
1111
PyMac_PRECHECK(PlotIconRef);
1113
if (!PyArg_ParseTuple(_args, "O&hhlO&",
1114
PyMac_GetRect, &theRect,
1117
&theIconServicesUsageFlags,
1118
ResObj_Convert, &theIconRef))
1120
_err = PlotIconRef(&theRect,
1123
theIconServicesUsageFlags,
1125
if (_err != noErr) return PyMac_Error(_err);
1131
static PyObject *Icn_PtInIconRef(PyObject *_self, PyObject *_args)
1133
PyObject *_res = NULL;
1137
IconAlignmentType align;
1138
IconServicesUsageFlags theIconServicesUsageFlags;
1141
PyMac_PRECHECK(PtInIconRef);
1143
if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1144
PyMac_GetPoint, &testPt,
1145
PyMac_GetRect, &iconRect,
1147
&theIconServicesUsageFlags,
1148
ResObj_Convert, &theIconRef))
1150
_rv = PtInIconRef(&testPt,
1153
theIconServicesUsageFlags,
1155
_res = Py_BuildValue("b",
1160
static PyObject *Icn_RectInIconRef(PyObject *_self, PyObject *_args)
1162
PyObject *_res = NULL;
1166
IconAlignmentType align;
1167
IconServicesUsageFlags iconServicesUsageFlags;
1169
#ifndef RectInIconRef
1170
PyMac_PRECHECK(RectInIconRef);
1172
if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1173
PyMac_GetRect, &testRect,
1174
PyMac_GetRect, &iconRect,
1176
&iconServicesUsageFlags,
1177
ResObj_Convert, &theIconRef))
1179
_rv = RectInIconRef(&testRect,
1182
iconServicesUsageFlags,
1184
_res = Py_BuildValue("b",
1189
static PyObject *Icn_IconRefToRgn(PyObject *_self, PyObject *_args)
1191
PyObject *_res = NULL;
1195
IconAlignmentType align;
1196
IconServicesUsageFlags iconServicesUsageFlags;
1198
#ifndef IconRefToRgn
1199
PyMac_PRECHECK(IconRefToRgn);
1201
if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1202
ResObj_Convert, &theRgn,
1203
PyMac_GetRect, &iconRect,
1205
&iconServicesUsageFlags,
1206
ResObj_Convert, &theIconRef))
1208
_err = IconRefToRgn(theRgn,
1211
iconServicesUsageFlags,
1213
if (_err != noErr) return PyMac_Error(_err);
1219
static PyObject *Icn_GetIconSizesFromIconRef(PyObject *_self, PyObject *_args)
1221
PyObject *_res = NULL;
1223
IconSelectorValue iconSelectorInput;
1224
IconSelectorValue iconSelectorOutputPtr;
1225
IconServicesUsageFlags iconServicesUsageFlags;
1227
#ifndef GetIconSizesFromIconRef
1228
PyMac_PRECHECK(GetIconSizesFromIconRef);
1230
if (!PyArg_ParseTuple(_args, "llO&",
1232
&iconServicesUsageFlags,
1233
ResObj_Convert, &theIconRef))
1235
_err = GetIconSizesFromIconRef(iconSelectorInput,
1236
&iconSelectorOutputPtr,
1237
iconServicesUsageFlags,
1239
if (_err != noErr) return PyMac_Error(_err);
1240
_res = Py_BuildValue("l",
1241
iconSelectorOutputPtr);
1245
static PyObject *Icn_FlushIconRefs(PyObject *_self, PyObject *_args)
1247
PyObject *_res = NULL;
1251
#ifndef FlushIconRefs
1252
PyMac_PRECHECK(FlushIconRefs);
1254
if (!PyArg_ParseTuple(_args, "O&O&",
1255
PyMac_GetOSType, &creator,
1256
PyMac_GetOSType, &iconType))
1258
_err = FlushIconRefs(creator,
1260
if (_err != noErr) return PyMac_Error(_err);
1266
static PyObject *Icn_FlushIconRefsByVolume(PyObject *_self, PyObject *_args)
1268
PyObject *_res = NULL;
1271
#ifndef FlushIconRefsByVolume
1272
PyMac_PRECHECK(FlushIconRefsByVolume);
1274
if (!PyArg_ParseTuple(_args, "h",
1277
_err = FlushIconRefsByVolume(vRefNum);
1278
if (_err != noErr) return PyMac_Error(_err);
1284
static PyObject *Icn_SetCustomIconsEnabled(PyObject *_self, PyObject *_args)
1286
PyObject *_res = NULL;
1289
Boolean enableCustomIcons;
1290
#ifndef SetCustomIconsEnabled
1291
PyMac_PRECHECK(SetCustomIconsEnabled);
1293
if (!PyArg_ParseTuple(_args, "hb",
1295
&enableCustomIcons))
1297
_err = SetCustomIconsEnabled(vRefNum,
1299
if (_err != noErr) return PyMac_Error(_err);
1305
static PyObject *Icn_GetCustomIconsEnabled(PyObject *_self, PyObject *_args)
1307
PyObject *_res = NULL;
1310
Boolean customIconsEnabled;
1311
#ifndef GetCustomIconsEnabled
1312
PyMac_PRECHECK(GetCustomIconsEnabled);
1314
if (!PyArg_ParseTuple(_args, "h",
1317
_err = GetCustomIconsEnabled(vRefNum,
1318
&customIconsEnabled);
1319
if (_err != noErr) return PyMac_Error(_err);
1320
_res = Py_BuildValue("b",
1321
customIconsEnabled);
1325
static PyObject *Icn_IsIconRefMaskEmpty(PyObject *_self, PyObject *_args)
1327
PyObject *_res = NULL;
1330
#ifndef IsIconRefMaskEmpty
1331
PyMac_PRECHECK(IsIconRefMaskEmpty);
1333
if (!PyArg_ParseTuple(_args, "O&",
1334
ResObj_Convert, &iconRef))
1336
_rv = IsIconRefMaskEmpty(iconRef);
1337
_res = Py_BuildValue("b",
1342
static PyObject *Icn_GetIconRefVariant(PyObject *_self, PyObject *_args)
1344
PyObject *_res = NULL;
1348
IconTransformType outTransform;
1349
#ifndef GetIconRefVariant
1350
PyMac_PRECHECK(GetIconRefVariant);
1352
if (!PyArg_ParseTuple(_args, "O&O&",
1353
ResObj_Convert, &inIconRef,
1354
PyMac_GetOSType, &inVariant))
1356
_rv = GetIconRefVariant(inIconRef,
1359
_res = Py_BuildValue("O&h",
1365
static PyObject *Icn_RegisterIconRefFromIconFile(PyObject *_self, PyObject *_args)
1367
PyObject *_res = NULL;
1373
#ifndef RegisterIconRefFromIconFile
1374
PyMac_PRECHECK(RegisterIconRefFromIconFile);
1376
if (!PyArg_ParseTuple(_args, "O&O&O&",
1377
PyMac_GetOSType, &creator,
1378
PyMac_GetOSType, &iconType,
1379
PyMac_GetFSSpec, &iconFile))
1381
_err = RegisterIconRefFromIconFile(creator,
1385
if (_err != noErr) return PyMac_Error(_err);
1386
_res = Py_BuildValue("O&",
1387
ResObj_New, theIconRef);
1391
static PyObject *Icn_ReadIconFile(PyObject *_self, PyObject *_args)
1393
PyObject *_res = NULL;
1396
IconFamilyHandle iconFamily;
1397
#ifndef ReadIconFile
1398
PyMac_PRECHECK(ReadIconFile);
1400
if (!PyArg_ParseTuple(_args, "O&",
1401
PyMac_GetFSSpec, &iconFile))
1403
_err = ReadIconFile(&iconFile,
1405
if (_err != noErr) return PyMac_Error(_err);
1406
_res = Py_BuildValue("O&",
1407
ResObj_New, iconFamily);
1411
static PyObject *Icn_ReadIconFromFSRef(PyObject *_self, PyObject *_args)
1413
PyObject *_res = NULL;
1416
IconFamilyHandle iconFamily;
1417
#ifndef ReadIconFromFSRef
1418
PyMac_PRECHECK(ReadIconFromFSRef);
1420
if (!PyArg_ParseTuple(_args, "O&",
1421
PyMac_GetFSRef, &ref))
1423
_err = ReadIconFromFSRef(&ref,
1425
if (_err != noErr) return PyMac_Error(_err);
1426
_res = Py_BuildValue("O&",
1427
ResObj_New, iconFamily);
1431
static PyObject *Icn_WriteIconFile(PyObject *_self, PyObject *_args)
1433
PyObject *_res = NULL;
1435
IconFamilyHandle iconFamily;
1437
#ifndef WriteIconFile
1438
PyMac_PRECHECK(WriteIconFile);
1440
if (!PyArg_ParseTuple(_args, "O&O&",
1441
ResObj_Convert, &iconFamily,
1442
PyMac_GetFSSpec, &iconFile))
1444
_err = WriteIconFile(iconFamily,
1446
if (_err != noErr) return PyMac_Error(_err);
1451
#endif /* __LP64__ */
1453
static PyMethodDef Icn_methods[] = {
1455
{"GetCIcon", (PyCFunction)Icn_GetCIcon, 1,
1456
PyDoc_STR("(SInt16 iconID) -> (CIconHandle _rv)")},
1457
{"PlotCIcon", (PyCFunction)Icn_PlotCIcon, 1,
1458
PyDoc_STR("(Rect theRect, CIconHandle theIcon) -> None")},
1459
{"DisposeCIcon", (PyCFunction)Icn_DisposeCIcon, 1,
1460
PyDoc_STR("(CIconHandle theIcon) -> None")},
1461
{"GetIcon", (PyCFunction)Icn_GetIcon, 1,
1462
PyDoc_STR("(SInt16 iconID) -> (Handle _rv)")},
1463
{"PlotIcon", (PyCFunction)Icn_PlotIcon, 1,
1464
PyDoc_STR("(Rect theRect, Handle theIcon) -> None")},
1465
{"PlotIconID", (PyCFunction)Icn_PlotIconID, 1,
1466
PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, SInt16 theResID) -> None")},
1467
{"NewIconSuite", (PyCFunction)Icn_NewIconSuite, 1,
1468
PyDoc_STR("() -> (IconSuiteRef theIconSuite)")},
1469
{"AddIconToSuite", (PyCFunction)Icn_AddIconToSuite, 1,
1470
PyDoc_STR("(Handle theIconData, IconSuiteRef theSuite, ResType theType) -> None")},
1471
{"GetIconFromSuite", (PyCFunction)Icn_GetIconFromSuite, 1,
1472
PyDoc_STR("(IconSuiteRef theSuite, ResType theType) -> (Handle theIconData)")},
1473
{"GetIconSuite", (PyCFunction)Icn_GetIconSuite, 1,
1474
PyDoc_STR("(SInt16 theResID, IconSelectorValue selector) -> (IconSuiteRef theIconSuite)")},
1475
{"DisposeIconSuite", (PyCFunction)Icn_DisposeIconSuite, 1,
1476
PyDoc_STR("(IconSuiteRef theIconSuite, Boolean disposeData) -> None")},
1477
{"PlotIconSuite", (PyCFunction)Icn_PlotIconSuite, 1,
1478
PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, IconSuiteRef theIconSuite) -> None")},
1479
{"LoadIconCache", (PyCFunction)Icn_LoadIconCache, 1,
1480
PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, IconCacheRef theIconCache) -> None")},
1481
{"GetLabel", (PyCFunction)Icn_GetLabel, 1,
1482
PyDoc_STR("(SInt16 labelNumber, Str255 labelString) -> (RGBColor labelColor)")},
1483
{"PtInIconID", (PyCFunction)Icn_PtInIconID, 1,
1484
PyDoc_STR("(Point testPt, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)")},
1485
{"PtInIconSuite", (PyCFunction)Icn_PtInIconSuite, 1,
1486
PyDoc_STR("(Point testPt, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)")},
1487
{"RectInIconID", (PyCFunction)Icn_RectInIconID, 1,
1488
PyDoc_STR("(Rect testRect, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)")},
1489
{"RectInIconSuite", (PyCFunction)Icn_RectInIconSuite, 1,
1490
PyDoc_STR("(Rect testRect, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)")},
1491
{"IconIDToRgn", (PyCFunction)Icn_IconIDToRgn, 1,
1492
PyDoc_STR("(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> None")},
1493
{"IconSuiteToRgn", (PyCFunction)Icn_IconSuiteToRgn, 1,
1494
PyDoc_STR("(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> None")},
1495
{"SetSuiteLabel", (PyCFunction)Icn_SetSuiteLabel, 1,
1496
PyDoc_STR("(IconSuiteRef theSuite, SInt16 theLabel) -> None")},
1497
{"GetSuiteLabel", (PyCFunction)Icn_GetSuiteLabel, 1,
1498
PyDoc_STR("(IconSuiteRef theSuite) -> (SInt16 _rv)")},
1499
{"PlotIconHandle", (PyCFunction)Icn_PlotIconHandle, 1,
1500
PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theIcon) -> None")},
1501
{"PlotSICNHandle", (PyCFunction)Icn_PlotSICNHandle, 1,
1502
PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theSICN) -> None")},
1503
{"PlotCIconHandle", (PyCFunction)Icn_PlotCIconHandle, 1,
1504
PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, CIconHandle theCIcon) -> None")},
1505
{"IconRefToIconFamily", (PyCFunction)Icn_IconRefToIconFamily, 1,
1506
PyDoc_STR("(IconRef theIconRef, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)")},
1507
{"IconFamilyToIconSuite", (PyCFunction)Icn_IconFamilyToIconSuite, 1,
1508
PyDoc_STR("(IconFamilyHandle iconFamily, IconSelectorValue whichIcons) -> (IconSuiteRef iconSuite)")},
1509
{"IconSuiteToIconFamily", (PyCFunction)Icn_IconSuiteToIconFamily, 1,
1510
PyDoc_STR("(IconSuiteRef iconSuite, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)")},
1511
{"SetIconFamilyData", (PyCFunction)Icn_SetIconFamilyData, 1,
1512
PyDoc_STR("(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None")},
1513
{"GetIconFamilyData", (PyCFunction)Icn_GetIconFamilyData, 1,
1514
PyDoc_STR("(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None")},
1515
{"GetIconRefOwners", (PyCFunction)Icn_GetIconRefOwners, 1,
1516
PyDoc_STR("(IconRef theIconRef) -> (UInt16 owners)")},
1517
{"AcquireIconRef", (PyCFunction)Icn_AcquireIconRef, 1,
1518
PyDoc_STR("(IconRef theIconRef) -> None")},
1519
{"ReleaseIconRef", (PyCFunction)Icn_ReleaseIconRef, 1,
1520
PyDoc_STR("(IconRef theIconRef) -> None")},
1521
{"GetIconRefFromFile", (PyCFunction)Icn_GetIconRefFromFile, 1,
1522
PyDoc_STR("(FSSpec theFile) -> (IconRef theIconRef, SInt16 theLabel)")},
1523
{"GetIconRef", (PyCFunction)Icn_GetIconRef, 1,
1524
PyDoc_STR("(SInt16 vRefNum, OSType creator, OSType iconType) -> (IconRef theIconRef)")},
1525
{"GetIconRefFromFolder", (PyCFunction)Icn_GetIconRefFromFolder, 1,
1526
PyDoc_STR("(SInt16 vRefNum, SInt32 parentFolderID, SInt32 folderID, SInt8 attributes, SInt8 accessPrivileges) -> (IconRef theIconRef)")},
1527
{"RegisterIconRefFromIconFamily", (PyCFunction)Icn_RegisterIconRefFromIconFamily, 1,
1528
PyDoc_STR("(OSType creator, OSType iconType, IconFamilyHandle iconFamily) -> (IconRef theIconRef)")},
1529
{"RegisterIconRefFromResource", (PyCFunction)Icn_RegisterIconRefFromResource, 1,
1530
PyDoc_STR("(OSType creator, OSType iconType, FSSpec resourceFile, SInt16 resourceID) -> (IconRef theIconRef)")},
1531
{"RegisterIconRefFromFSRef", (PyCFunction)Icn_RegisterIconRefFromFSRef, 1,
1532
PyDoc_STR("(OSType creator, OSType iconType, FSRef iconFile) -> (IconRef theIconRef)")},
1533
{"UnregisterIconRef", (PyCFunction)Icn_UnregisterIconRef, 1,
1534
PyDoc_STR("(OSType creator, OSType iconType) -> None")},
1535
{"UpdateIconRef", (PyCFunction)Icn_UpdateIconRef, 1,
1536
PyDoc_STR("(IconRef theIconRef) -> None")},
1537
{"OverrideIconRefFromResource", (PyCFunction)Icn_OverrideIconRefFromResource, 1,
1538
PyDoc_STR("(IconRef theIconRef, FSSpec resourceFile, SInt16 resourceID) -> None")},
1539
{"OverrideIconRef", (PyCFunction)Icn_OverrideIconRef, 1,
1540
PyDoc_STR("(IconRef oldIconRef, IconRef newIconRef) -> None")},
1541
{"RemoveIconRefOverride", (PyCFunction)Icn_RemoveIconRefOverride, 1,
1542
PyDoc_STR("(IconRef theIconRef) -> None")},
1543
{"CompositeIconRef", (PyCFunction)Icn_CompositeIconRef, 1,
1544
PyDoc_STR("(IconRef backgroundIconRef, IconRef foregroundIconRef) -> (IconRef compositeIconRef)")},
1545
{"IsIconRefComposite", (PyCFunction)Icn_IsIconRefComposite, 1,
1546
PyDoc_STR("(IconRef compositeIconRef) -> (IconRef backgroundIconRef, IconRef foregroundIconRef)")},
1547
{"IsValidIconRef", (PyCFunction)Icn_IsValidIconRef, 1,
1548
PyDoc_STR("(IconRef theIconRef) -> (Boolean _rv)")},
1549
{"PlotIconRef", (PyCFunction)Icn_PlotIconRef, 1,
1550
PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> None")},
1551
{"PtInIconRef", (PyCFunction)Icn_PtInIconRef, 1,
1552
PyDoc_STR("(Point testPt, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)")},
1553
{"RectInIconRef", (PyCFunction)Icn_RectInIconRef, 1,
1554
PyDoc_STR("(Rect testRect, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)")},
1555
{"IconRefToRgn", (PyCFunction)Icn_IconRefToRgn, 1,
1556
PyDoc_STR("(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> None")},
1557
{"GetIconSizesFromIconRef", (PyCFunction)Icn_GetIconSizesFromIconRef, 1,
1558
PyDoc_STR("(IconSelectorValue iconSelectorInput, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (IconSelectorValue iconSelectorOutputPtr)")},
1559
{"FlushIconRefs", (PyCFunction)Icn_FlushIconRefs, 1,
1560
PyDoc_STR("(OSType creator, OSType iconType) -> None")},
1561
{"FlushIconRefsByVolume", (PyCFunction)Icn_FlushIconRefsByVolume, 1,
1562
PyDoc_STR("(SInt16 vRefNum) -> None")},
1563
{"SetCustomIconsEnabled", (PyCFunction)Icn_SetCustomIconsEnabled, 1,
1564
PyDoc_STR("(SInt16 vRefNum, Boolean enableCustomIcons) -> None")},
1565
{"GetCustomIconsEnabled", (PyCFunction)Icn_GetCustomIconsEnabled, 1,
1566
PyDoc_STR("(SInt16 vRefNum) -> (Boolean customIconsEnabled)")},
1567
{"IsIconRefMaskEmpty", (PyCFunction)Icn_IsIconRefMaskEmpty, 1,
1568
PyDoc_STR("(IconRef iconRef) -> (Boolean _rv)")},
1569
{"GetIconRefVariant", (PyCFunction)Icn_GetIconRefVariant, 1,
1570
PyDoc_STR("(IconRef inIconRef, OSType inVariant) -> (IconRef _rv, IconTransformType outTransform)")},
1571
{"RegisterIconRefFromIconFile", (PyCFunction)Icn_RegisterIconRefFromIconFile, 1,
1572
PyDoc_STR("(OSType creator, OSType iconType, FSSpec iconFile) -> (IconRef theIconRef)")},
1573
{"ReadIconFile", (PyCFunction)Icn_ReadIconFile, 1,
1574
PyDoc_STR("(FSSpec iconFile) -> (IconFamilyHandle iconFamily)")},
1575
{"ReadIconFromFSRef", (PyCFunction)Icn_ReadIconFromFSRef, 1,
1576
PyDoc_STR("(FSRef ref) -> (IconFamilyHandle iconFamily)")},
1577
{"WriteIconFile", (PyCFunction)Icn_WriteIconFile, 1,
1578
PyDoc_STR("(IconFamilyHandle iconFamily, FSSpec iconFile) -> None")},
1579
#endif /* __LP64__ */
1591
#endif /* __LP64__ */
1596
m = Py_InitModule("_Icn", Icn_methods);
1598
d = PyModule_GetDict(m);
1599
Icn_Error = PyMac_GetOSErrException();
1600
if (Icn_Error == NULL ||
1601
PyDict_SetItemString(d, "Error", Icn_Error) != 0)
1603
#endif /* __LP64__ */
1606
/* ======================== End module _Icn ========================= */