2 /* =========================== Module Icn =========================== */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern int ResObj_Convert(PyObject
*, Handle
*);
18 extern PyObject
*OptResObj_New(Handle
);
19 extern int OptResObj_Convert(PyObject
*, Handle
*);
21 extern PyObject
*WinObj_New(WindowPtr
);
22 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyTypeObject Window_Type
;
24 #define WinObj_Check(x) ((x)->ob_type == &Window_Type)
26 extern PyObject
*DlgObj_New(DialogPtr
);
27 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
28 extern PyTypeObject Dialog_Type
;
29 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
31 extern PyObject
*MenuObj_New(MenuHandle
);
32 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
34 extern PyObject
*CtlObj_New(ControlHandle
);
35 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
37 extern PyObject
*GrafObj_New(GrafPtr
);
38 extern int GrafObj_Convert(PyObject
*, GrafPtr
*);
40 extern PyObject
*BMObj_New(BitMapPtr
);
41 extern int BMObj_Convert(PyObject
*, BitMapPtr
*);
43 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
47 /* Exported by Qdmodule.c: */
48 extern PyObject
*QdRGB_New(RGBColor
*);
49 extern int QdRGB_Convert(PyObject
*, RGBColor
*);
51 #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
53 static PyObject
*Icn_Error
;
55 static PyObject
*Icn_GetCIcon(_self
, _args
)
59 PyObject
*_res
= NULL
;
62 if (!PyArg_ParseTuple(_args
, "h",
65 _rv
= GetCIcon(iconID
);
66 _res
= Py_BuildValue("O&",
71 static PyObject
*Icn_PlotCIcon(_self
, _args
)
75 PyObject
*_res
= NULL
;
78 if (!PyArg_ParseTuple(_args
, "O&O&",
79 PyMac_GetRect
, &theRect
,
80 ResObj_Convert
, &theIcon
))
89 static PyObject
*Icn_DisposeCIcon(_self
, _args
)
93 PyObject
*_res
= NULL
;
95 if (!PyArg_ParseTuple(_args
, "O&",
96 ResObj_Convert
, &theIcon
))
98 DisposeCIcon(theIcon
);
104 static PyObject
*Icn_GetIcon(_self
, _args
)
108 PyObject
*_res
= NULL
;
111 if (!PyArg_ParseTuple(_args
, "h",
114 _rv
= GetIcon(iconID
);
115 _res
= Py_BuildValue("O&",
120 static PyObject
*Icn_PlotIcon(_self
, _args
)
124 PyObject
*_res
= NULL
;
127 if (!PyArg_ParseTuple(_args
, "O&O&",
128 PyMac_GetRect
, &theRect
,
129 ResObj_Convert
, &theIcon
))
138 static PyObject
*Icn_PlotIconID(_self
, _args
)
142 PyObject
*_res
= NULL
;
145 IconAlignmentType align
;
146 IconTransformType transform
;
148 if (!PyArg_ParseTuple(_args
, "O&hhh",
149 PyMac_GetRect
, &theRect
,
154 _err
= PlotIconID(&theRect
,
158 if (_err
!= noErr
) return PyMac_Error(_err
);
164 static PyObject
*Icn_NewIconSuite(_self
, _args
)
168 PyObject
*_res
= NULL
;
170 IconSuiteRef theIconSuite
;
171 if (!PyArg_ParseTuple(_args
, ""))
173 _err
= NewIconSuite(&theIconSuite
);
174 if (_err
!= noErr
) return PyMac_Error(_err
);
175 _res
= Py_BuildValue("O&",
176 ResObj_New
, theIconSuite
);
180 static PyObject
*Icn_AddIconToSuite(_self
, _args
)
184 PyObject
*_res
= NULL
;
187 IconSuiteRef theSuite
;
189 if (!PyArg_ParseTuple(_args
, "O&O&O&",
190 ResObj_Convert
, &theIconData
,
191 ResObj_Convert
, &theSuite
,
192 PyMac_GetOSType
, &theType
))
194 _err
= AddIconToSuite(theIconData
,
197 if (_err
!= noErr
) return PyMac_Error(_err
);
203 static PyObject
*Icn_GetIconFromSuite(_self
, _args
)
207 PyObject
*_res
= NULL
;
210 IconSuiteRef theSuite
;
212 if (!PyArg_ParseTuple(_args
, "O&O&",
213 ResObj_Convert
, &theSuite
,
214 PyMac_GetOSType
, &theType
))
216 _err
= GetIconFromSuite(&theIconData
,
219 if (_err
!= noErr
) return PyMac_Error(_err
);
220 _res
= Py_BuildValue("O&",
221 ResObj_New
, theIconData
);
225 static PyObject
*Icn_GetIconSuite(_self
, _args
)
229 PyObject
*_res
= NULL
;
231 IconSuiteRef theIconSuite
;
233 IconSelectorValue selector
;
234 if (!PyArg_ParseTuple(_args
, "hl",
238 _err
= GetIconSuite(&theIconSuite
,
241 if (_err
!= noErr
) return PyMac_Error(_err
);
242 _res
= Py_BuildValue("O&",
243 ResObj_New
, theIconSuite
);
247 static PyObject
*Icn_DisposeIconSuite(_self
, _args
)
251 PyObject
*_res
= NULL
;
253 IconSuiteRef theIconSuite
;
255 if (!PyArg_ParseTuple(_args
, "O&b",
256 ResObj_Convert
, &theIconSuite
,
259 _err
= DisposeIconSuite(theIconSuite
,
261 if (_err
!= noErr
) return PyMac_Error(_err
);
267 static PyObject
*Icn_PlotIconSuite(_self
, _args
)
271 PyObject
*_res
= NULL
;
274 IconAlignmentType align
;
275 IconTransformType transform
;
276 IconSuiteRef theIconSuite
;
277 if (!PyArg_ParseTuple(_args
, "O&hhO&",
278 PyMac_GetRect
, &theRect
,
281 ResObj_Convert
, &theIconSuite
))
283 _err
= PlotIconSuite(&theRect
,
287 if (_err
!= noErr
) return PyMac_Error(_err
);
293 static PyObject
*Icn_LoadIconCache(_self
, _args
)
297 PyObject
*_res
= NULL
;
300 IconAlignmentType align
;
301 IconTransformType transform
;
302 IconCacheRef theIconCache
;
303 if (!PyArg_ParseTuple(_args
, "O&hhO&",
304 PyMac_GetRect
, &theRect
,
307 ResObj_Convert
, &theIconCache
))
309 _err
= LoadIconCache(&theRect
,
313 if (_err
!= noErr
) return PyMac_Error(_err
);
319 static PyObject
*Icn_GetLabel(_self
, _args
)
323 PyObject
*_res
= NULL
;
328 if (!PyArg_ParseTuple(_args
, "hO&",
330 PyMac_GetStr255
, labelString
))
332 _err
= GetLabel(labelNumber
,
335 if (_err
!= noErr
) return PyMac_Error(_err
);
336 _res
= Py_BuildValue("O&",
337 QdRGB_New
, &labelColor
);
341 static PyObject
*Icn_PtInIconID(_self
, _args
)
345 PyObject
*_res
= NULL
;
349 IconAlignmentType align
;
351 if (!PyArg_ParseTuple(_args
, "O&O&hh",
352 PyMac_GetPoint
, &testPt
,
353 PyMac_GetRect
, &iconRect
,
357 _rv
= PtInIconID(testPt
,
361 _res
= Py_BuildValue("b",
366 static PyObject
*Icn_PtInIconSuite(_self
, _args
)
370 PyObject
*_res
= NULL
;
374 IconAlignmentType align
;
375 IconSuiteRef theIconSuite
;
376 if (!PyArg_ParseTuple(_args
, "O&O&hO&",
377 PyMac_GetPoint
, &testPt
,
378 PyMac_GetRect
, &iconRect
,
380 ResObj_Convert
, &theIconSuite
))
382 _rv
= PtInIconSuite(testPt
,
386 _res
= Py_BuildValue("b",
391 static PyObject
*Icn_RectInIconID(_self
, _args
)
395 PyObject
*_res
= NULL
;
399 IconAlignmentType align
;
401 if (!PyArg_ParseTuple(_args
, "O&O&hh",
402 PyMac_GetRect
, &testRect
,
403 PyMac_GetRect
, &iconRect
,
407 _rv
= RectInIconID(&testRect
,
411 _res
= Py_BuildValue("b",
416 static PyObject
*Icn_RectInIconSuite(_self
, _args
)
420 PyObject
*_res
= NULL
;
424 IconAlignmentType align
;
425 IconSuiteRef theIconSuite
;
426 if (!PyArg_ParseTuple(_args
, "O&O&hO&",
427 PyMac_GetRect
, &testRect
,
428 PyMac_GetRect
, &iconRect
,
430 ResObj_Convert
, &theIconSuite
))
432 _rv
= RectInIconSuite(&testRect
,
436 _res
= Py_BuildValue("b",
441 static PyObject
*Icn_IconIDToRgn(_self
, _args
)
445 PyObject
*_res
= NULL
;
449 IconAlignmentType align
;
451 if (!PyArg_ParseTuple(_args
, "O&O&hh",
452 ResObj_Convert
, &theRgn
,
453 PyMac_GetRect
, &iconRect
,
457 _err
= IconIDToRgn(theRgn
,
461 if (_err
!= noErr
) return PyMac_Error(_err
);
467 static PyObject
*Icn_IconSuiteToRgn(_self
, _args
)
471 PyObject
*_res
= NULL
;
475 IconAlignmentType align
;
476 IconSuiteRef theIconSuite
;
477 if (!PyArg_ParseTuple(_args
, "O&O&hO&",
478 ResObj_Convert
, &theRgn
,
479 PyMac_GetRect
, &iconRect
,
481 ResObj_Convert
, &theIconSuite
))
483 _err
= IconSuiteToRgn(theRgn
,
487 if (_err
!= noErr
) return PyMac_Error(_err
);
493 static PyObject
*Icn_SetSuiteLabel(_self
, _args
)
497 PyObject
*_res
= NULL
;
499 IconSuiteRef theSuite
;
501 if (!PyArg_ParseTuple(_args
, "O&h",
502 ResObj_Convert
, &theSuite
,
505 _err
= SetSuiteLabel(theSuite
,
507 if (_err
!= noErr
) return PyMac_Error(_err
);
513 static PyObject
*Icn_GetSuiteLabel(_self
, _args
)
517 PyObject
*_res
= NULL
;
519 IconSuiteRef theSuite
;
520 if (!PyArg_ParseTuple(_args
, "O&",
521 ResObj_Convert
, &theSuite
))
523 _rv
= GetSuiteLabel(theSuite
);
524 _res
= Py_BuildValue("h",
529 static PyObject
*Icn_PlotIconHandle(_self
, _args
)
533 PyObject
*_res
= NULL
;
536 IconAlignmentType align
;
537 IconTransformType transform
;
539 if (!PyArg_ParseTuple(_args
, "O&hhO&",
540 PyMac_GetRect
, &theRect
,
543 ResObj_Convert
, &theIcon
))
545 _err
= PlotIconHandle(&theRect
,
549 if (_err
!= noErr
) return PyMac_Error(_err
);
555 static PyObject
*Icn_PlotSICNHandle(_self
, _args
)
559 PyObject
*_res
= NULL
;
562 IconAlignmentType align
;
563 IconTransformType transform
;
565 if (!PyArg_ParseTuple(_args
, "O&hhO&",
566 PyMac_GetRect
, &theRect
,
569 ResObj_Convert
, &theSICN
))
571 _err
= PlotSICNHandle(&theRect
,
575 if (_err
!= noErr
) return PyMac_Error(_err
);
581 static PyObject
*Icn_PlotCIconHandle(_self
, _args
)
585 PyObject
*_res
= NULL
;
588 IconAlignmentType align
;
589 IconTransformType transform
;
590 CIconHandle theCIcon
;
591 if (!PyArg_ParseTuple(_args
, "O&hhO&",
592 PyMac_GetRect
, &theRect
,
595 ResObj_Convert
, &theCIcon
))
597 _err
= PlotCIconHandle(&theRect
,
601 if (_err
!= noErr
) return PyMac_Error(_err
);
607 static PyObject
*Icn_IconServicesTerminate(_self
, _args
)
611 PyObject
*_res
= NULL
;
612 if (!PyArg_ParseTuple(_args
, ""))
614 IconServicesTerminate();
620 static PyObject
*Icn_IconRefToIconFamily(_self
, _args
)
624 PyObject
*_res
= NULL
;
627 IconSelectorValue whichIcons
;
628 IconFamilyHandle iconFamily
;
629 if (!PyArg_ParseTuple(_args
, "O&l",
630 ResObj_Convert
, &theIconRef
,
633 _err
= IconRefToIconFamily(theIconRef
,
636 if (_err
!= noErr
) return PyMac_Error(_err
);
637 _res
= Py_BuildValue("O&",
638 ResObj_New
, iconFamily
);
642 static PyObject
*Icn_IconFamilyToIconSuite(_self
, _args
)
646 PyObject
*_res
= NULL
;
648 IconFamilyHandle iconFamily
;
649 IconSelectorValue whichIcons
;
650 IconSuiteRef iconSuite
;
651 if (!PyArg_ParseTuple(_args
, "O&l",
652 ResObj_Convert
, &iconFamily
,
655 _err
= IconFamilyToIconSuite(iconFamily
,
658 if (_err
!= noErr
) return PyMac_Error(_err
);
659 _res
= Py_BuildValue("O&",
660 ResObj_New
, iconSuite
);
664 static PyObject
*Icn_IconSuiteToIconFamily(_self
, _args
)
668 PyObject
*_res
= NULL
;
670 IconSuiteRef iconSuite
;
671 IconSelectorValue whichIcons
;
672 IconFamilyHandle iconFamily
;
673 if (!PyArg_ParseTuple(_args
, "O&l",
674 ResObj_Convert
, &iconSuite
,
677 _err
= IconSuiteToIconFamily(iconSuite
,
680 if (_err
!= noErr
) return PyMac_Error(_err
);
681 _res
= Py_BuildValue("O&",
682 ResObj_New
, iconFamily
);
686 static PyObject
*Icn_SetIconFamilyData(_self
, _args
)
690 PyObject
*_res
= NULL
;
692 IconFamilyHandle iconFamily
;
695 if (!PyArg_ParseTuple(_args
, "O&O&O&",
696 ResObj_Convert
, &iconFamily
,
697 PyMac_GetOSType
, &iconType
,
700 _err
= SetIconFamilyData(iconFamily
,
703 if (_err
!= noErr
) return PyMac_Error(_err
);
709 static PyObject
*Icn_GetIconFamilyData(_self
, _args
)
713 PyObject
*_res
= NULL
;
715 IconFamilyHandle iconFamily
;
718 if (!PyArg_ParseTuple(_args
, "O&O&O&",
719 ResObj_Convert
, &iconFamily
,
720 PyMac_GetOSType
, &iconType
,
723 _err
= GetIconFamilyData(iconFamily
,
726 if (_err
!= noErr
) return PyMac_Error(_err
);
732 static PyObject
*Icn_GetIconRefOwners(_self
, _args
)
736 PyObject
*_res
= NULL
;
740 if (!PyArg_ParseTuple(_args
, "O&",
741 ResObj_Convert
, &theIconRef
))
743 _err
= GetIconRefOwners(theIconRef
,
745 if (_err
!= noErr
) return PyMac_Error(_err
);
746 _res
= Py_BuildValue("h",
751 static PyObject
*Icn_AcquireIconRef(_self
, _args
)
755 PyObject
*_res
= NULL
;
758 if (!PyArg_ParseTuple(_args
, "O&",
759 ResObj_Convert
, &theIconRef
))
761 _err
= AcquireIconRef(theIconRef
);
762 if (_err
!= noErr
) return PyMac_Error(_err
);
768 static PyObject
*Icn_ReleaseIconRef(_self
, _args
)
772 PyObject
*_res
= NULL
;
775 if (!PyArg_ParseTuple(_args
, "O&",
776 ResObj_Convert
, &theIconRef
))
778 _err
= ReleaseIconRef(theIconRef
);
779 if (_err
!= noErr
) return PyMac_Error(_err
);
785 static PyObject
*Icn_GetIconRefFromFile(_self
, _args
)
789 PyObject
*_res
= NULL
;
794 if (!PyArg_ParseTuple(_args
, "O&",
795 PyMac_GetFSSpec
, &theFile
))
797 _err
= GetIconRefFromFile(&theFile
,
800 if (_err
!= noErr
) return PyMac_Error(_err
);
801 _res
= Py_BuildValue("O&h",
802 ResObj_New
, theIconRef
,
807 static PyObject
*Icn_GetIconRef(_self
, _args
)
811 PyObject
*_res
= NULL
;
817 if (!PyArg_ParseTuple(_args
, "hO&O&",
819 PyMac_GetOSType
, &creator
,
820 PyMac_GetOSType
, &iconType
))
822 _err
= GetIconRef(vRefNum
,
826 if (_err
!= noErr
) return PyMac_Error(_err
);
827 _res
= Py_BuildValue("O&",
828 ResObj_New
, theIconRef
);
832 static PyObject
*Icn_GetIconRefFromFolder(_self
, _args
)
836 PyObject
*_res
= NULL
;
839 SInt32 parentFolderID
;
842 SInt8 accessPrivileges
;
844 if (!PyArg_ParseTuple(_args
, "hllbb",
851 _err
= GetIconRefFromFolder(vRefNum
,
857 if (_err
!= noErr
) return PyMac_Error(_err
);
858 _res
= Py_BuildValue("O&",
859 ResObj_New
, theIconRef
);
863 static PyObject
*Icn_RegisterIconRefFromIconFamily(_self
, _args
)
867 PyObject
*_res
= NULL
;
871 IconFamilyHandle iconFamily
;
873 if (!PyArg_ParseTuple(_args
, "O&O&O&",
874 PyMac_GetOSType
, &creator
,
875 PyMac_GetOSType
, &iconType
,
876 ResObj_Convert
, &iconFamily
))
878 _err
= RegisterIconRefFromIconFamily(creator
,
882 if (_err
!= noErr
) return PyMac_Error(_err
);
883 _res
= Py_BuildValue("O&",
884 ResObj_New
, theIconRef
);
888 static PyObject
*Icn_RegisterIconRefFromResource(_self
, _args
)
892 PyObject
*_res
= NULL
;
899 if (!PyArg_ParseTuple(_args
, "O&O&O&h",
900 PyMac_GetOSType
, &creator
,
901 PyMac_GetOSType
, &iconType
,
902 PyMac_GetFSSpec
, &resourceFile
,
905 _err
= RegisterIconRefFromResource(creator
,
910 if (_err
!= noErr
) return PyMac_Error(_err
);
911 _res
= Py_BuildValue("O&",
912 ResObj_New
, theIconRef
);
916 static PyObject
*Icn_UnregisterIconRef(_self
, _args
)
920 PyObject
*_res
= NULL
;
924 if (!PyArg_ParseTuple(_args
, "O&O&",
925 PyMac_GetOSType
, &creator
,
926 PyMac_GetOSType
, &iconType
))
928 _err
= UnregisterIconRef(creator
,
930 if (_err
!= noErr
) return PyMac_Error(_err
);
936 static PyObject
*Icn_UpdateIconRef(_self
, _args
)
940 PyObject
*_res
= NULL
;
943 if (!PyArg_ParseTuple(_args
, "O&",
944 ResObj_Convert
, &theIconRef
))
946 _err
= UpdateIconRef(theIconRef
);
947 if (_err
!= noErr
) return PyMac_Error(_err
);
953 static PyObject
*Icn_OverrideIconRefFromResource(_self
, _args
)
957 PyObject
*_res
= NULL
;
962 if (!PyArg_ParseTuple(_args
, "O&O&h",
963 ResObj_Convert
, &theIconRef
,
964 PyMac_GetFSSpec
, &resourceFile
,
967 _err
= OverrideIconRefFromResource(theIconRef
,
970 if (_err
!= noErr
) return PyMac_Error(_err
);
976 static PyObject
*Icn_OverrideIconRef(_self
, _args
)
980 PyObject
*_res
= NULL
;
984 if (!PyArg_ParseTuple(_args
, "O&O&",
985 ResObj_Convert
, &oldIconRef
,
986 ResObj_Convert
, &newIconRef
))
988 _err
= OverrideIconRef(oldIconRef
,
990 if (_err
!= noErr
) return PyMac_Error(_err
);
996 static PyObject
*Icn_RemoveIconRefOverride(_self
, _args
)
1000 PyObject
*_res
= NULL
;
1003 if (!PyArg_ParseTuple(_args
, "O&",
1004 ResObj_Convert
, &theIconRef
))
1006 _err
= RemoveIconRefOverride(theIconRef
);
1007 if (_err
!= noErr
) return PyMac_Error(_err
);
1013 static PyObject
*Icn_CompositeIconRef(_self
, _args
)
1017 PyObject
*_res
= NULL
;
1019 IconRef backgroundIconRef
;
1020 IconRef foregroundIconRef
;
1021 IconRef compositeIconRef
;
1022 if (!PyArg_ParseTuple(_args
, "O&O&",
1023 ResObj_Convert
, &backgroundIconRef
,
1024 ResObj_Convert
, &foregroundIconRef
))
1026 _err
= CompositeIconRef(backgroundIconRef
,
1029 if (_err
!= noErr
) return PyMac_Error(_err
);
1030 _res
= Py_BuildValue("O&",
1031 ResObj_New
, compositeIconRef
);
1035 static PyObject
*Icn_IsIconRefComposite(_self
, _args
)
1039 PyObject
*_res
= NULL
;
1041 IconRef compositeIconRef
;
1042 IconRef backgroundIconRef
;
1043 IconRef foregroundIconRef
;
1044 if (!PyArg_ParseTuple(_args
, "O&",
1045 ResObj_Convert
, &compositeIconRef
))
1047 _err
= IsIconRefComposite(compositeIconRef
,
1049 &foregroundIconRef
);
1050 if (_err
!= noErr
) return PyMac_Error(_err
);
1051 _res
= Py_BuildValue("O&O&",
1052 ResObj_New
, backgroundIconRef
,
1053 ResObj_New
, foregroundIconRef
);
1057 static PyObject
*Icn_IsValidIconRef(_self
, _args
)
1061 PyObject
*_res
= NULL
;
1064 if (!PyArg_ParseTuple(_args
, "O&",
1065 ResObj_Convert
, &theIconRef
))
1067 _rv
= IsValidIconRef(theIconRef
);
1068 _res
= Py_BuildValue("b",
1073 static PyObject
*Icn_PlotIconRef(_self
, _args
)
1077 PyObject
*_res
= NULL
;
1080 IconAlignmentType align
;
1081 IconTransformType transform
;
1082 IconServicesUsageFlags theIconServicesUsageFlags
;
1084 if (!PyArg_ParseTuple(_args
, "O&hhlO&",
1085 PyMac_GetRect
, &theRect
,
1088 &theIconServicesUsageFlags
,
1089 ResObj_Convert
, &theIconRef
))
1091 _err
= PlotIconRef(&theRect
,
1094 theIconServicesUsageFlags
,
1096 if (_err
!= noErr
) return PyMac_Error(_err
);
1102 static PyObject
*Icn_PtInIconRef(_self
, _args
)
1106 PyObject
*_res
= NULL
;
1110 IconAlignmentType align
;
1111 IconServicesUsageFlags theIconServicesUsageFlags
;
1113 if (!PyArg_ParseTuple(_args
, "O&O&hlO&",
1114 PyMac_GetPoint
, &testPt
,
1115 PyMac_GetRect
, &iconRect
,
1117 &theIconServicesUsageFlags
,
1118 ResObj_Convert
, &theIconRef
))
1120 _rv
= PtInIconRef(&testPt
,
1123 theIconServicesUsageFlags
,
1125 _res
= Py_BuildValue("b",
1130 static PyObject
*Icn_RectInIconRef(_self
, _args
)
1134 PyObject
*_res
= NULL
;
1138 IconAlignmentType align
;
1139 IconServicesUsageFlags iconServicesUsageFlags
;
1141 if (!PyArg_ParseTuple(_args
, "O&O&hlO&",
1142 PyMac_GetRect
, &testRect
,
1143 PyMac_GetRect
, &iconRect
,
1145 &iconServicesUsageFlags
,
1146 ResObj_Convert
, &theIconRef
))
1148 _rv
= RectInIconRef(&testRect
,
1151 iconServicesUsageFlags
,
1153 _res
= Py_BuildValue("b",
1158 static PyObject
*Icn_IconRefToRgn(_self
, _args
)
1162 PyObject
*_res
= NULL
;
1166 IconAlignmentType align
;
1167 IconServicesUsageFlags iconServicesUsageFlags
;
1169 if (!PyArg_ParseTuple(_args
, "O&O&hlO&",
1170 ResObj_Convert
, &theRgn
,
1171 PyMac_GetRect
, &iconRect
,
1173 &iconServicesUsageFlags
,
1174 ResObj_Convert
, &theIconRef
))
1176 _err
= IconRefToRgn(theRgn
,
1179 iconServicesUsageFlags
,
1181 if (_err
!= noErr
) return PyMac_Error(_err
);
1187 static PyObject
*Icn_GetIconSizesFromIconRef(_self
, _args
)
1191 PyObject
*_res
= NULL
;
1193 IconSelectorValue iconSelectorInput
;
1194 IconSelectorValue iconSelectorOutputPtr
;
1195 IconServicesUsageFlags iconServicesUsageFlags
;
1197 if (!PyArg_ParseTuple(_args
, "llO&",
1199 &iconServicesUsageFlags
,
1200 ResObj_Convert
, &theIconRef
))
1202 _err
= GetIconSizesFromIconRef(iconSelectorInput
,
1203 &iconSelectorOutputPtr
,
1204 iconServicesUsageFlags
,
1206 if (_err
!= noErr
) return PyMac_Error(_err
);
1207 _res
= Py_BuildValue("l",
1208 iconSelectorOutputPtr
);
1212 static PyObject
*Icn_FlushIconRefs(_self
, _args
)
1216 PyObject
*_res
= NULL
;
1220 if (!PyArg_ParseTuple(_args
, "O&O&",
1221 PyMac_GetOSType
, &creator
,
1222 PyMac_GetOSType
, &iconType
))
1224 _err
= FlushIconRefs(creator
,
1226 if (_err
!= noErr
) return PyMac_Error(_err
);
1232 static PyObject
*Icn_FlushIconRefsByVolume(_self
, _args
)
1236 PyObject
*_res
= NULL
;
1239 if (!PyArg_ParseTuple(_args
, "h",
1242 _err
= FlushIconRefsByVolume(vRefNum
);
1243 if (_err
!= noErr
) return PyMac_Error(_err
);
1249 static PyObject
*Icn_SetCustomIconsEnabled(_self
, _args
)
1253 PyObject
*_res
= NULL
;
1256 Boolean enableCustomIcons
;
1257 if (!PyArg_ParseTuple(_args
, "hb",
1259 &enableCustomIcons
))
1261 _err
= SetCustomIconsEnabled(vRefNum
,
1263 if (_err
!= noErr
) return PyMac_Error(_err
);
1269 static PyObject
*Icn_GetCustomIconsEnabled(_self
, _args
)
1273 PyObject
*_res
= NULL
;
1276 Boolean customIconsEnabled
;
1277 if (!PyArg_ParseTuple(_args
, "h",
1280 _err
= GetCustomIconsEnabled(vRefNum
,
1281 &customIconsEnabled
);
1282 if (_err
!= noErr
) return PyMac_Error(_err
);
1283 _res
= Py_BuildValue("b",
1284 customIconsEnabled
);
1288 static PyMethodDef Icn_methods
[] = {
1289 {"GetCIcon", (PyCFunction
)Icn_GetCIcon
, 1,
1290 "(SInt16 iconID) -> (CIconHandle _rv)"},
1291 {"PlotCIcon", (PyCFunction
)Icn_PlotCIcon
, 1,
1292 "(Rect theRect, CIconHandle theIcon) -> None"},
1293 {"DisposeCIcon", (PyCFunction
)Icn_DisposeCIcon
, 1,
1294 "(CIconHandle theIcon) -> None"},
1295 {"GetIcon", (PyCFunction
)Icn_GetIcon
, 1,
1296 "(SInt16 iconID) -> (Handle _rv)"},
1297 {"PlotIcon", (PyCFunction
)Icn_PlotIcon
, 1,
1298 "(Rect theRect, Handle theIcon) -> None"},
1299 {"PlotIconID", (PyCFunction
)Icn_PlotIconID
, 1,
1300 "(Rect theRect, IconAlignmentType align, IconTransformType transform, SInt16 theResID) -> None"},
1301 {"NewIconSuite", (PyCFunction
)Icn_NewIconSuite
, 1,
1302 "() -> (IconSuiteRef theIconSuite)"},
1303 {"AddIconToSuite", (PyCFunction
)Icn_AddIconToSuite
, 1,
1304 "(Handle theIconData, IconSuiteRef theSuite, ResType theType) -> None"},
1305 {"GetIconFromSuite", (PyCFunction
)Icn_GetIconFromSuite
, 1,
1306 "(IconSuiteRef theSuite, ResType theType) -> (Handle theIconData)"},
1307 {"GetIconSuite", (PyCFunction
)Icn_GetIconSuite
, 1,
1308 "(SInt16 theResID, IconSelectorValue selector) -> (IconSuiteRef theIconSuite)"},
1309 {"DisposeIconSuite", (PyCFunction
)Icn_DisposeIconSuite
, 1,
1310 "(IconSuiteRef theIconSuite, Boolean disposeData) -> None"},
1311 {"PlotIconSuite", (PyCFunction
)Icn_PlotIconSuite
, 1,
1312 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconSuiteRef theIconSuite) -> None"},
1313 {"LoadIconCache", (PyCFunction
)Icn_LoadIconCache
, 1,
1314 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconCacheRef theIconCache) -> None"},
1315 {"GetLabel", (PyCFunction
)Icn_GetLabel
, 1,
1316 "(SInt16 labelNumber, Str255 labelString) -> (RGBColor labelColor)"},
1317 {"PtInIconID", (PyCFunction
)Icn_PtInIconID
, 1,
1318 "(Point testPt, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)"},
1319 {"PtInIconSuite", (PyCFunction
)Icn_PtInIconSuite
, 1,
1320 "(Point testPt, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)"},
1321 {"RectInIconID", (PyCFunction
)Icn_RectInIconID
, 1,
1322 "(Rect testRect, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)"},
1323 {"RectInIconSuite", (PyCFunction
)Icn_RectInIconSuite
, 1,
1324 "(Rect testRect, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)"},
1325 {"IconIDToRgn", (PyCFunction
)Icn_IconIDToRgn
, 1,
1326 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> None"},
1327 {"IconSuiteToRgn", (PyCFunction
)Icn_IconSuiteToRgn
, 1,
1328 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> None"},
1329 {"SetSuiteLabel", (PyCFunction
)Icn_SetSuiteLabel
, 1,
1330 "(IconSuiteRef theSuite, SInt16 theLabel) -> None"},
1331 {"GetSuiteLabel", (PyCFunction
)Icn_GetSuiteLabel
, 1,
1332 "(IconSuiteRef theSuite) -> (SInt16 _rv)"},
1333 {"PlotIconHandle", (PyCFunction
)Icn_PlotIconHandle
, 1,
1334 "(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theIcon) -> None"},
1335 {"PlotSICNHandle", (PyCFunction
)Icn_PlotSICNHandle
, 1,
1336 "(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theSICN) -> None"},
1337 {"PlotCIconHandle", (PyCFunction
)Icn_PlotCIconHandle
, 1,
1338 "(Rect theRect, IconAlignmentType align, IconTransformType transform, CIconHandle theCIcon) -> None"},
1339 {"IconServicesTerminate", (PyCFunction
)Icn_IconServicesTerminate
, 1,
1341 {"IconRefToIconFamily", (PyCFunction
)Icn_IconRefToIconFamily
, 1,
1342 "(IconRef theIconRef, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)"},
1343 {"IconFamilyToIconSuite", (PyCFunction
)Icn_IconFamilyToIconSuite
, 1,
1344 "(IconFamilyHandle iconFamily, IconSelectorValue whichIcons) -> (IconSuiteRef iconSuite)"},
1345 {"IconSuiteToIconFamily", (PyCFunction
)Icn_IconSuiteToIconFamily
, 1,
1346 "(IconSuiteRef iconSuite, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)"},
1347 {"SetIconFamilyData", (PyCFunction
)Icn_SetIconFamilyData
, 1,
1348 "(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None"},
1349 {"GetIconFamilyData", (PyCFunction
)Icn_GetIconFamilyData
, 1,
1350 "(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None"},
1351 {"GetIconRefOwners", (PyCFunction
)Icn_GetIconRefOwners
, 1,
1352 "(IconRef theIconRef) -> (UInt16 owners)"},
1353 {"AcquireIconRef", (PyCFunction
)Icn_AcquireIconRef
, 1,
1354 "(IconRef theIconRef) -> None"},
1355 {"ReleaseIconRef", (PyCFunction
)Icn_ReleaseIconRef
, 1,
1356 "(IconRef theIconRef) -> None"},
1357 {"GetIconRefFromFile", (PyCFunction
)Icn_GetIconRefFromFile
, 1,
1358 "(FSSpec theFile) -> (IconRef theIconRef, SInt16 theLabel)"},
1359 {"GetIconRef", (PyCFunction
)Icn_GetIconRef
, 1,
1360 "(SInt16 vRefNum, OSType creator, OSType iconType) -> (IconRef theIconRef)"},
1361 {"GetIconRefFromFolder", (PyCFunction
)Icn_GetIconRefFromFolder
, 1,
1362 "(SInt16 vRefNum, SInt32 parentFolderID, SInt32 folderID, SInt8 attributes, SInt8 accessPrivileges) -> (IconRef theIconRef)"},
1363 {"RegisterIconRefFromIconFamily", (PyCFunction
)Icn_RegisterIconRefFromIconFamily
, 1,
1364 "(OSType creator, OSType iconType, IconFamilyHandle iconFamily) -> (IconRef theIconRef)"},
1365 {"RegisterIconRefFromResource", (PyCFunction
)Icn_RegisterIconRefFromResource
, 1,
1366 "(OSType creator, OSType iconType, FSSpec resourceFile, SInt16 resourceID) -> (IconRef theIconRef)"},
1367 {"UnregisterIconRef", (PyCFunction
)Icn_UnregisterIconRef
, 1,
1368 "(OSType creator, OSType iconType) -> None"},
1369 {"UpdateIconRef", (PyCFunction
)Icn_UpdateIconRef
, 1,
1370 "(IconRef theIconRef) -> None"},
1371 {"OverrideIconRefFromResource", (PyCFunction
)Icn_OverrideIconRefFromResource
, 1,
1372 "(IconRef theIconRef, FSSpec resourceFile, SInt16 resourceID) -> None"},
1373 {"OverrideIconRef", (PyCFunction
)Icn_OverrideIconRef
, 1,
1374 "(IconRef oldIconRef, IconRef newIconRef) -> None"},
1375 {"RemoveIconRefOverride", (PyCFunction
)Icn_RemoveIconRefOverride
, 1,
1376 "(IconRef theIconRef) -> None"},
1377 {"CompositeIconRef", (PyCFunction
)Icn_CompositeIconRef
, 1,
1378 "(IconRef backgroundIconRef, IconRef foregroundIconRef) -> (IconRef compositeIconRef)"},
1379 {"IsIconRefComposite", (PyCFunction
)Icn_IsIconRefComposite
, 1,
1380 "(IconRef compositeIconRef) -> (IconRef backgroundIconRef, IconRef foregroundIconRef)"},
1381 {"IsValidIconRef", (PyCFunction
)Icn_IsValidIconRef
, 1,
1382 "(IconRef theIconRef) -> (Boolean _rv)"},
1383 {"PlotIconRef", (PyCFunction
)Icn_PlotIconRef
, 1,
1384 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> None"},
1385 {"PtInIconRef", (PyCFunction
)Icn_PtInIconRef
, 1,
1386 "(Point testPt, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)"},
1387 {"RectInIconRef", (PyCFunction
)Icn_RectInIconRef
, 1,
1388 "(Rect testRect, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)"},
1389 {"IconRefToRgn", (PyCFunction
)Icn_IconRefToRgn
, 1,
1390 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> None"},
1391 {"GetIconSizesFromIconRef", (PyCFunction
)Icn_GetIconSizesFromIconRef
, 1,
1392 "(IconSelectorValue iconSelectorInput, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (IconSelectorValue iconSelectorOutputPtr)"},
1393 {"FlushIconRefs", (PyCFunction
)Icn_FlushIconRefs
, 1,
1394 "(OSType creator, OSType iconType) -> None"},
1395 {"FlushIconRefsByVolume", (PyCFunction
)Icn_FlushIconRefsByVolume
, 1,
1396 "(SInt16 vRefNum) -> None"},
1397 {"SetCustomIconsEnabled", (PyCFunction
)Icn_SetCustomIconsEnabled
, 1,
1398 "(SInt16 vRefNum, Boolean enableCustomIcons) -> None"},
1399 {"GetCustomIconsEnabled", (PyCFunction
)Icn_GetCustomIconsEnabled
, 1,
1400 "(SInt16 vRefNum) -> (Boolean customIconsEnabled)"},
1415 m
= Py_InitModule("Icn", Icn_methods
);
1416 d
= PyModule_GetDict(m
);
1417 Icn_Error
= PyMac_GetOSErrException();
1418 if (Icn_Error
== NULL
||
1419 PyDict_SetItemString(d
, "Error", Icn_Error
) != 0)
1420 Py_FatalError("can't initialize Icn.Error");
1423 /* ========================= End module Icn ========================= */