This commit was manufactured by cvs2svn to create tag 'r221'.
[python/dscho.git] / Mac / Modules / icn / _Icnmodule.c
blob19930dfff0834a5217056c9819ea1ba603faa375
2 /* ========================== Module _Icn =========================== */
4 #include "Python.h"
8 #ifdef _WIN32
9 #include "pywintoolbox.h"
10 #else
11 #include "macglue.h"
12 #include "pymactoolbox.h"
13 #endif
15 /* Macro to test whether a weak-loaded CFM function exists */
16 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
19 return NULL; \
20 }} while(0)
23 #ifdef WITHOUT_FRAMEWORKS
24 #include <Icons.h>
25 #else
26 #include <Carbon/Carbon.h>
27 #endif
30 static PyObject *Icn_Error;
32 static PyObject *Icn_GetCIcon(PyObject *_self, PyObject *_args)
34 PyObject *_res = NULL;
35 CIconHandle _rv;
36 SInt16 iconID;
37 #ifndef GetCIcon
38 PyMac_PRECHECK(GetCIcon);
39 #endif
40 if (!PyArg_ParseTuple(_args, "h",
41 &iconID))
42 return NULL;
43 _rv = GetCIcon(iconID);
44 _res = Py_BuildValue("O&",
45 ResObj_New, _rv);
46 return _res;
49 static PyObject *Icn_PlotCIcon(PyObject *_self, PyObject *_args)
51 PyObject *_res = NULL;
52 Rect theRect;
53 CIconHandle theIcon;
54 #ifndef PlotCIcon
55 PyMac_PRECHECK(PlotCIcon);
56 #endif
57 if (!PyArg_ParseTuple(_args, "O&O&",
58 PyMac_GetRect, &theRect,
59 ResObj_Convert, &theIcon))
60 return NULL;
61 PlotCIcon(&theRect,
62 theIcon);
63 Py_INCREF(Py_None);
64 _res = Py_None;
65 return _res;
68 static PyObject *Icn_DisposeCIcon(PyObject *_self, PyObject *_args)
70 PyObject *_res = NULL;
71 CIconHandle theIcon;
72 #ifndef DisposeCIcon
73 PyMac_PRECHECK(DisposeCIcon);
74 #endif
75 if (!PyArg_ParseTuple(_args, "O&",
76 ResObj_Convert, &theIcon))
77 return NULL;
78 DisposeCIcon(theIcon);
79 Py_INCREF(Py_None);
80 _res = Py_None;
81 return _res;
84 static PyObject *Icn_GetIcon(PyObject *_self, PyObject *_args)
86 PyObject *_res = NULL;
87 Handle _rv;
88 SInt16 iconID;
89 #ifndef GetIcon
90 PyMac_PRECHECK(GetIcon);
91 #endif
92 if (!PyArg_ParseTuple(_args, "h",
93 &iconID))
94 return NULL;
95 _rv = GetIcon(iconID);
96 _res = Py_BuildValue("O&",
97 ResObj_New, _rv);
98 return _res;
101 static PyObject *Icn_PlotIcon(PyObject *_self, PyObject *_args)
103 PyObject *_res = NULL;
104 Rect theRect;
105 Handle theIcon;
106 #ifndef PlotIcon
107 PyMac_PRECHECK(PlotIcon);
108 #endif
109 if (!PyArg_ParseTuple(_args, "O&O&",
110 PyMac_GetRect, &theRect,
111 ResObj_Convert, &theIcon))
112 return NULL;
113 PlotIcon(&theRect,
114 theIcon);
115 Py_INCREF(Py_None);
116 _res = Py_None;
117 return _res;
120 static PyObject *Icn_PlotIconID(PyObject *_self, PyObject *_args)
122 PyObject *_res = NULL;
123 OSErr _err;
124 Rect theRect;
125 IconAlignmentType align;
126 IconTransformType transform;
127 SInt16 theResID;
128 #ifndef PlotIconID
129 PyMac_PRECHECK(PlotIconID);
130 #endif
131 if (!PyArg_ParseTuple(_args, "O&hhh",
132 PyMac_GetRect, &theRect,
133 &align,
134 &transform,
135 &theResID))
136 return NULL;
137 _err = PlotIconID(&theRect,
138 align,
139 transform,
140 theResID);
141 if (_err != noErr) return PyMac_Error(_err);
142 Py_INCREF(Py_None);
143 _res = Py_None;
144 return _res;
147 static PyObject *Icn_NewIconSuite(PyObject *_self, PyObject *_args)
149 PyObject *_res = NULL;
150 OSErr _err;
151 IconSuiteRef theIconSuite;
152 #ifndef NewIconSuite
153 PyMac_PRECHECK(NewIconSuite);
154 #endif
155 if (!PyArg_ParseTuple(_args, ""))
156 return NULL;
157 _err = NewIconSuite(&theIconSuite);
158 if (_err != noErr) return PyMac_Error(_err);
159 _res = Py_BuildValue("O&",
160 ResObj_New, theIconSuite);
161 return _res;
164 static PyObject *Icn_AddIconToSuite(PyObject *_self, PyObject *_args)
166 PyObject *_res = NULL;
167 OSErr _err;
168 Handle theIconData;
169 IconSuiteRef theSuite;
170 ResType theType;
171 #ifndef AddIconToSuite
172 PyMac_PRECHECK(AddIconToSuite);
173 #endif
174 if (!PyArg_ParseTuple(_args, "O&O&O&",
175 ResObj_Convert, &theIconData,
176 ResObj_Convert, &theSuite,
177 PyMac_GetOSType, &theType))
178 return NULL;
179 _err = AddIconToSuite(theIconData,
180 theSuite,
181 theType);
182 if (_err != noErr) return PyMac_Error(_err);
183 Py_INCREF(Py_None);
184 _res = Py_None;
185 return _res;
188 static PyObject *Icn_GetIconFromSuite(PyObject *_self, PyObject *_args)
190 PyObject *_res = NULL;
191 OSErr _err;
192 Handle theIconData;
193 IconSuiteRef theSuite;
194 ResType theType;
195 #ifndef GetIconFromSuite
196 PyMac_PRECHECK(GetIconFromSuite);
197 #endif
198 if (!PyArg_ParseTuple(_args, "O&O&",
199 ResObj_Convert, &theSuite,
200 PyMac_GetOSType, &theType))
201 return NULL;
202 _err = GetIconFromSuite(&theIconData,
203 theSuite,
204 theType);
205 if (_err != noErr) return PyMac_Error(_err);
206 _res = Py_BuildValue("O&",
207 ResObj_New, theIconData);
208 return _res;
211 static PyObject *Icn_GetIconSuite(PyObject *_self, PyObject *_args)
213 PyObject *_res = NULL;
214 OSErr _err;
215 IconSuiteRef theIconSuite;
216 SInt16 theResID;
217 IconSelectorValue selector;
218 #ifndef GetIconSuite
219 PyMac_PRECHECK(GetIconSuite);
220 #endif
221 if (!PyArg_ParseTuple(_args, "hl",
222 &theResID,
223 &selector))
224 return NULL;
225 _err = GetIconSuite(&theIconSuite,
226 theResID,
227 selector);
228 if (_err != noErr) return PyMac_Error(_err);
229 _res = Py_BuildValue("O&",
230 ResObj_New, theIconSuite);
231 return _res;
234 static PyObject *Icn_DisposeIconSuite(PyObject *_self, PyObject *_args)
236 PyObject *_res = NULL;
237 OSErr _err;
238 IconSuiteRef theIconSuite;
239 Boolean disposeData;
240 #ifndef DisposeIconSuite
241 PyMac_PRECHECK(DisposeIconSuite);
242 #endif
243 if (!PyArg_ParseTuple(_args, "O&b",
244 ResObj_Convert, &theIconSuite,
245 &disposeData))
246 return NULL;
247 _err = DisposeIconSuite(theIconSuite,
248 disposeData);
249 if (_err != noErr) return PyMac_Error(_err);
250 Py_INCREF(Py_None);
251 _res = Py_None;
252 return _res;
255 static PyObject *Icn_PlotIconSuite(PyObject *_self, PyObject *_args)
257 PyObject *_res = NULL;
258 OSErr _err;
259 Rect theRect;
260 IconAlignmentType align;
261 IconTransformType transform;
262 IconSuiteRef theIconSuite;
263 #ifndef PlotIconSuite
264 PyMac_PRECHECK(PlotIconSuite);
265 #endif
266 if (!PyArg_ParseTuple(_args, "O&hhO&",
267 PyMac_GetRect, &theRect,
268 &align,
269 &transform,
270 ResObj_Convert, &theIconSuite))
271 return NULL;
272 _err = PlotIconSuite(&theRect,
273 align,
274 transform,
275 theIconSuite);
276 if (_err != noErr) return PyMac_Error(_err);
277 Py_INCREF(Py_None);
278 _res = Py_None;
279 return _res;
282 static PyObject *Icn_LoadIconCache(PyObject *_self, PyObject *_args)
284 PyObject *_res = NULL;
285 OSErr _err;
286 Rect theRect;
287 IconAlignmentType align;
288 IconTransformType transform;
289 IconCacheRef theIconCache;
290 #ifndef LoadIconCache
291 PyMac_PRECHECK(LoadIconCache);
292 #endif
293 if (!PyArg_ParseTuple(_args, "O&hhO&",
294 PyMac_GetRect, &theRect,
295 &align,
296 &transform,
297 ResObj_Convert, &theIconCache))
298 return NULL;
299 _err = LoadIconCache(&theRect,
300 align,
301 transform,
302 theIconCache);
303 if (_err != noErr) return PyMac_Error(_err);
304 Py_INCREF(Py_None);
305 _res = Py_None;
306 return _res;
309 static PyObject *Icn_GetLabel(PyObject *_self, PyObject *_args)
311 PyObject *_res = NULL;
312 OSErr _err;
313 SInt16 labelNumber;
314 RGBColor labelColor;
315 Str255 labelString;
316 #ifndef GetLabel
317 PyMac_PRECHECK(GetLabel);
318 #endif
319 if (!PyArg_ParseTuple(_args, "hO&",
320 &labelNumber,
321 PyMac_GetStr255, labelString))
322 return NULL;
323 _err = GetLabel(labelNumber,
324 &labelColor,
325 labelString);
326 if (_err != noErr) return PyMac_Error(_err);
327 _res = Py_BuildValue("O&",
328 QdRGB_New, &labelColor);
329 return _res;
332 static PyObject *Icn_PtInIconID(PyObject *_self, PyObject *_args)
334 PyObject *_res = NULL;
335 Boolean _rv;
336 Point testPt;
337 Rect iconRect;
338 IconAlignmentType align;
339 SInt16 iconID;
340 #ifndef PtInIconID
341 PyMac_PRECHECK(PtInIconID);
342 #endif
343 if (!PyArg_ParseTuple(_args, "O&O&hh",
344 PyMac_GetPoint, &testPt,
345 PyMac_GetRect, &iconRect,
346 &align,
347 &iconID))
348 return NULL;
349 _rv = PtInIconID(testPt,
350 &iconRect,
351 align,
352 iconID);
353 _res = Py_BuildValue("b",
354 _rv);
355 return _res;
358 static PyObject *Icn_PtInIconSuite(PyObject *_self, PyObject *_args)
360 PyObject *_res = NULL;
361 Boolean _rv;
362 Point testPt;
363 Rect iconRect;
364 IconAlignmentType align;
365 IconSuiteRef theIconSuite;
366 #ifndef PtInIconSuite
367 PyMac_PRECHECK(PtInIconSuite);
368 #endif
369 if (!PyArg_ParseTuple(_args, "O&O&hO&",
370 PyMac_GetPoint, &testPt,
371 PyMac_GetRect, &iconRect,
372 &align,
373 ResObj_Convert, &theIconSuite))
374 return NULL;
375 _rv = PtInIconSuite(testPt,
376 &iconRect,
377 align,
378 theIconSuite);
379 _res = Py_BuildValue("b",
380 _rv);
381 return _res;
384 static PyObject *Icn_RectInIconID(PyObject *_self, PyObject *_args)
386 PyObject *_res = NULL;
387 Boolean _rv;
388 Rect testRect;
389 Rect iconRect;
390 IconAlignmentType align;
391 SInt16 iconID;
392 #ifndef RectInIconID
393 PyMac_PRECHECK(RectInIconID);
394 #endif
395 if (!PyArg_ParseTuple(_args, "O&O&hh",
396 PyMac_GetRect, &testRect,
397 PyMac_GetRect, &iconRect,
398 &align,
399 &iconID))
400 return NULL;
401 _rv = RectInIconID(&testRect,
402 &iconRect,
403 align,
404 iconID);
405 _res = Py_BuildValue("b",
406 _rv);
407 return _res;
410 static PyObject *Icn_RectInIconSuite(PyObject *_self, PyObject *_args)
412 PyObject *_res = NULL;
413 Boolean _rv;
414 Rect testRect;
415 Rect iconRect;
416 IconAlignmentType align;
417 IconSuiteRef theIconSuite;
418 #ifndef RectInIconSuite
419 PyMac_PRECHECK(RectInIconSuite);
420 #endif
421 if (!PyArg_ParseTuple(_args, "O&O&hO&",
422 PyMac_GetRect, &testRect,
423 PyMac_GetRect, &iconRect,
424 &align,
425 ResObj_Convert, &theIconSuite))
426 return NULL;
427 _rv = RectInIconSuite(&testRect,
428 &iconRect,
429 align,
430 theIconSuite);
431 _res = Py_BuildValue("b",
432 _rv);
433 return _res;
436 static PyObject *Icn_IconIDToRgn(PyObject *_self, PyObject *_args)
438 PyObject *_res = NULL;
439 OSErr _err;
440 RgnHandle theRgn;
441 Rect iconRect;
442 IconAlignmentType align;
443 SInt16 iconID;
444 #ifndef IconIDToRgn
445 PyMac_PRECHECK(IconIDToRgn);
446 #endif
447 if (!PyArg_ParseTuple(_args, "O&O&hh",
448 ResObj_Convert, &theRgn,
449 PyMac_GetRect, &iconRect,
450 &align,
451 &iconID))
452 return NULL;
453 _err = IconIDToRgn(theRgn,
454 &iconRect,
455 align,
456 iconID);
457 if (_err != noErr) return PyMac_Error(_err);
458 Py_INCREF(Py_None);
459 _res = Py_None;
460 return _res;
463 static PyObject *Icn_IconSuiteToRgn(PyObject *_self, PyObject *_args)
465 PyObject *_res = NULL;
466 OSErr _err;
467 RgnHandle theRgn;
468 Rect iconRect;
469 IconAlignmentType align;
470 IconSuiteRef theIconSuite;
471 #ifndef IconSuiteToRgn
472 PyMac_PRECHECK(IconSuiteToRgn);
473 #endif
474 if (!PyArg_ParseTuple(_args, "O&O&hO&",
475 ResObj_Convert, &theRgn,
476 PyMac_GetRect, &iconRect,
477 &align,
478 ResObj_Convert, &theIconSuite))
479 return NULL;
480 _err = IconSuiteToRgn(theRgn,
481 &iconRect,
482 align,
483 theIconSuite);
484 if (_err != noErr) return PyMac_Error(_err);
485 Py_INCREF(Py_None);
486 _res = Py_None;
487 return _res;
490 static PyObject *Icn_SetSuiteLabel(PyObject *_self, PyObject *_args)
492 PyObject *_res = NULL;
493 OSErr _err;
494 IconSuiteRef theSuite;
495 SInt16 theLabel;
496 #ifndef SetSuiteLabel
497 PyMac_PRECHECK(SetSuiteLabel);
498 #endif
499 if (!PyArg_ParseTuple(_args, "O&h",
500 ResObj_Convert, &theSuite,
501 &theLabel))
502 return NULL;
503 _err = SetSuiteLabel(theSuite,
504 theLabel);
505 if (_err != noErr) return PyMac_Error(_err);
506 Py_INCREF(Py_None);
507 _res = Py_None;
508 return _res;
511 static PyObject *Icn_GetSuiteLabel(PyObject *_self, PyObject *_args)
513 PyObject *_res = NULL;
514 SInt16 _rv;
515 IconSuiteRef theSuite;
516 #ifndef GetSuiteLabel
517 PyMac_PRECHECK(GetSuiteLabel);
518 #endif
519 if (!PyArg_ParseTuple(_args, "O&",
520 ResObj_Convert, &theSuite))
521 return NULL;
522 _rv = GetSuiteLabel(theSuite);
523 _res = Py_BuildValue("h",
524 _rv);
525 return _res;
528 static PyObject *Icn_PlotIconHandle(PyObject *_self, PyObject *_args)
530 PyObject *_res = NULL;
531 OSErr _err;
532 Rect theRect;
533 IconAlignmentType align;
534 IconTransformType transform;
535 Handle theIcon;
536 #ifndef PlotIconHandle
537 PyMac_PRECHECK(PlotIconHandle);
538 #endif
539 if (!PyArg_ParseTuple(_args, "O&hhO&",
540 PyMac_GetRect, &theRect,
541 &align,
542 &transform,
543 ResObj_Convert, &theIcon))
544 return NULL;
545 _err = PlotIconHandle(&theRect,
546 align,
547 transform,
548 theIcon);
549 if (_err != noErr) return PyMac_Error(_err);
550 Py_INCREF(Py_None);
551 _res = Py_None;
552 return _res;
555 static PyObject *Icn_PlotSICNHandle(PyObject *_self, PyObject *_args)
557 PyObject *_res = NULL;
558 OSErr _err;
559 Rect theRect;
560 IconAlignmentType align;
561 IconTransformType transform;
562 Handle theSICN;
563 #ifndef PlotSICNHandle
564 PyMac_PRECHECK(PlotSICNHandle);
565 #endif
566 if (!PyArg_ParseTuple(_args, "O&hhO&",
567 PyMac_GetRect, &theRect,
568 &align,
569 &transform,
570 ResObj_Convert, &theSICN))
571 return NULL;
572 _err = PlotSICNHandle(&theRect,
573 align,
574 transform,
575 theSICN);
576 if (_err != noErr) return PyMac_Error(_err);
577 Py_INCREF(Py_None);
578 _res = Py_None;
579 return _res;
582 static PyObject *Icn_PlotCIconHandle(PyObject *_self, PyObject *_args)
584 PyObject *_res = NULL;
585 OSErr _err;
586 Rect theRect;
587 IconAlignmentType align;
588 IconTransformType transform;
589 CIconHandle theCIcon;
590 #ifndef PlotCIconHandle
591 PyMac_PRECHECK(PlotCIconHandle);
592 #endif
593 if (!PyArg_ParseTuple(_args, "O&hhO&",
594 PyMac_GetRect, &theRect,
595 &align,
596 &transform,
597 ResObj_Convert, &theCIcon))
598 return NULL;
599 _err = PlotCIconHandle(&theRect,
600 align,
601 transform,
602 theCIcon);
603 if (_err != noErr) return PyMac_Error(_err);
604 Py_INCREF(Py_None);
605 _res = Py_None;
606 return _res;
609 #if !TARGET_API_MAC_CARBON
611 static PyObject *Icn_IconServicesTerminate(PyObject *_self, PyObject *_args)
613 PyObject *_res = NULL;
614 #ifndef IconServicesTerminate
615 PyMac_PRECHECK(IconServicesTerminate);
616 #endif
617 if (!PyArg_ParseTuple(_args, ""))
618 return NULL;
619 IconServicesTerminate();
620 Py_INCREF(Py_None);
621 _res = Py_None;
622 return _res;
624 #endif
626 static PyObject *Icn_IconRefToIconFamily(PyObject *_self, PyObject *_args)
628 PyObject *_res = NULL;
629 OSErr _err;
630 IconRef theIconRef;
631 IconSelectorValue whichIcons;
632 IconFamilyHandle iconFamily;
633 #ifndef IconRefToIconFamily
634 PyMac_PRECHECK(IconRefToIconFamily);
635 #endif
636 if (!PyArg_ParseTuple(_args, "O&l",
637 ResObj_Convert, &theIconRef,
638 &whichIcons))
639 return NULL;
640 _err = IconRefToIconFamily(theIconRef,
641 whichIcons,
642 &iconFamily);
643 if (_err != noErr) return PyMac_Error(_err);
644 _res = Py_BuildValue("O&",
645 ResObj_New, iconFamily);
646 return _res;
649 static PyObject *Icn_IconFamilyToIconSuite(PyObject *_self, PyObject *_args)
651 PyObject *_res = NULL;
652 OSErr _err;
653 IconFamilyHandle iconFamily;
654 IconSelectorValue whichIcons;
655 IconSuiteRef iconSuite;
656 #ifndef IconFamilyToIconSuite
657 PyMac_PRECHECK(IconFamilyToIconSuite);
658 #endif
659 if (!PyArg_ParseTuple(_args, "O&l",
660 ResObj_Convert, &iconFamily,
661 &whichIcons))
662 return NULL;
663 _err = IconFamilyToIconSuite(iconFamily,
664 whichIcons,
665 &iconSuite);
666 if (_err != noErr) return PyMac_Error(_err);
667 _res = Py_BuildValue("O&",
668 ResObj_New, iconSuite);
669 return _res;
672 static PyObject *Icn_IconSuiteToIconFamily(PyObject *_self, PyObject *_args)
674 PyObject *_res = NULL;
675 OSErr _err;
676 IconSuiteRef iconSuite;
677 IconSelectorValue whichIcons;
678 IconFamilyHandle iconFamily;
679 #ifndef IconSuiteToIconFamily
680 PyMac_PRECHECK(IconSuiteToIconFamily);
681 #endif
682 if (!PyArg_ParseTuple(_args, "O&l",
683 ResObj_Convert, &iconSuite,
684 &whichIcons))
685 return NULL;
686 _err = IconSuiteToIconFamily(iconSuite,
687 whichIcons,
688 &iconFamily);
689 if (_err != noErr) return PyMac_Error(_err);
690 _res = Py_BuildValue("O&",
691 ResObj_New, iconFamily);
692 return _res;
695 static PyObject *Icn_SetIconFamilyData(PyObject *_self, PyObject *_args)
697 PyObject *_res = NULL;
698 OSErr _err;
699 IconFamilyHandle iconFamily;
700 OSType iconType;
701 Handle h;
702 #ifndef SetIconFamilyData
703 PyMac_PRECHECK(SetIconFamilyData);
704 #endif
705 if (!PyArg_ParseTuple(_args, "O&O&O&",
706 ResObj_Convert, &iconFamily,
707 PyMac_GetOSType, &iconType,
708 ResObj_Convert, &h))
709 return NULL;
710 _err = SetIconFamilyData(iconFamily,
711 iconType,
713 if (_err != noErr) return PyMac_Error(_err);
714 Py_INCREF(Py_None);
715 _res = Py_None;
716 return _res;
719 static PyObject *Icn_GetIconFamilyData(PyObject *_self, PyObject *_args)
721 PyObject *_res = NULL;
722 OSErr _err;
723 IconFamilyHandle iconFamily;
724 OSType iconType;
725 Handle h;
726 #ifndef GetIconFamilyData
727 PyMac_PRECHECK(GetIconFamilyData);
728 #endif
729 if (!PyArg_ParseTuple(_args, "O&O&O&",
730 ResObj_Convert, &iconFamily,
731 PyMac_GetOSType, &iconType,
732 ResObj_Convert, &h))
733 return NULL;
734 _err = GetIconFamilyData(iconFamily,
735 iconType,
737 if (_err != noErr) return PyMac_Error(_err);
738 Py_INCREF(Py_None);
739 _res = Py_None;
740 return _res;
743 static PyObject *Icn_GetIconRefOwners(PyObject *_self, PyObject *_args)
745 PyObject *_res = NULL;
746 OSErr _err;
747 IconRef theIconRef;
748 UInt16 owners;
749 #ifndef GetIconRefOwners
750 PyMac_PRECHECK(GetIconRefOwners);
751 #endif
752 if (!PyArg_ParseTuple(_args, "O&",
753 ResObj_Convert, &theIconRef))
754 return NULL;
755 _err = GetIconRefOwners(theIconRef,
756 &owners);
757 if (_err != noErr) return PyMac_Error(_err);
758 _res = Py_BuildValue("H",
759 owners);
760 return _res;
763 static PyObject *Icn_AcquireIconRef(PyObject *_self, PyObject *_args)
765 PyObject *_res = NULL;
766 OSErr _err;
767 IconRef theIconRef;
768 #ifndef AcquireIconRef
769 PyMac_PRECHECK(AcquireIconRef);
770 #endif
771 if (!PyArg_ParseTuple(_args, "O&",
772 ResObj_Convert, &theIconRef))
773 return NULL;
774 _err = AcquireIconRef(theIconRef);
775 if (_err != noErr) return PyMac_Error(_err);
776 Py_INCREF(Py_None);
777 _res = Py_None;
778 return _res;
781 static PyObject *Icn_ReleaseIconRef(PyObject *_self, PyObject *_args)
783 PyObject *_res = NULL;
784 OSErr _err;
785 IconRef theIconRef;
786 #ifndef ReleaseIconRef
787 PyMac_PRECHECK(ReleaseIconRef);
788 #endif
789 if (!PyArg_ParseTuple(_args, "O&",
790 ResObj_Convert, &theIconRef))
791 return NULL;
792 _err = ReleaseIconRef(theIconRef);
793 if (_err != noErr) return PyMac_Error(_err);
794 Py_INCREF(Py_None);
795 _res = Py_None;
796 return _res;
799 static PyObject *Icn_GetIconRefFromFile(PyObject *_self, PyObject *_args)
801 PyObject *_res = NULL;
802 OSErr _err;
803 FSSpec theFile;
804 IconRef theIconRef;
805 SInt16 theLabel;
806 #ifndef GetIconRefFromFile
807 PyMac_PRECHECK(GetIconRefFromFile);
808 #endif
809 if (!PyArg_ParseTuple(_args, "O&",
810 PyMac_GetFSSpec, &theFile))
811 return NULL;
812 _err = GetIconRefFromFile(&theFile,
813 &theIconRef,
814 &theLabel);
815 if (_err != noErr) return PyMac_Error(_err);
816 _res = Py_BuildValue("O&h",
817 ResObj_New, theIconRef,
818 theLabel);
819 return _res;
822 static PyObject *Icn_GetIconRef(PyObject *_self, PyObject *_args)
824 PyObject *_res = NULL;
825 OSErr _err;
826 SInt16 vRefNum;
827 OSType creator;
828 OSType iconType;
829 IconRef theIconRef;
830 #ifndef GetIconRef
831 PyMac_PRECHECK(GetIconRef);
832 #endif
833 if (!PyArg_ParseTuple(_args, "hO&O&",
834 &vRefNum,
835 PyMac_GetOSType, &creator,
836 PyMac_GetOSType, &iconType))
837 return NULL;
838 _err = GetIconRef(vRefNum,
839 creator,
840 iconType,
841 &theIconRef);
842 if (_err != noErr) return PyMac_Error(_err);
843 _res = Py_BuildValue("O&",
844 ResObj_New, theIconRef);
845 return _res;
848 static PyObject *Icn_GetIconRefFromFolder(PyObject *_self, PyObject *_args)
850 PyObject *_res = NULL;
851 OSErr _err;
852 SInt16 vRefNum;
853 SInt32 parentFolderID;
854 SInt32 folderID;
855 SInt8 attributes;
856 SInt8 accessPrivileges;
857 IconRef theIconRef;
858 #ifndef GetIconRefFromFolder
859 PyMac_PRECHECK(GetIconRefFromFolder);
860 #endif
861 if (!PyArg_ParseTuple(_args, "hllbb",
862 &vRefNum,
863 &parentFolderID,
864 &folderID,
865 &attributes,
866 &accessPrivileges))
867 return NULL;
868 _err = GetIconRefFromFolder(vRefNum,
869 parentFolderID,
870 folderID,
871 attributes,
872 accessPrivileges,
873 &theIconRef);
874 if (_err != noErr) return PyMac_Error(_err);
875 _res = Py_BuildValue("O&",
876 ResObj_New, theIconRef);
877 return _res;
880 static PyObject *Icn_RegisterIconRefFromIconFamily(PyObject *_self, PyObject *_args)
882 PyObject *_res = NULL;
883 OSErr _err;
884 OSType creator;
885 OSType iconType;
886 IconFamilyHandle iconFamily;
887 IconRef theIconRef;
888 #ifndef RegisterIconRefFromIconFamily
889 PyMac_PRECHECK(RegisterIconRefFromIconFamily);
890 #endif
891 if (!PyArg_ParseTuple(_args, "O&O&O&",
892 PyMac_GetOSType, &creator,
893 PyMac_GetOSType, &iconType,
894 ResObj_Convert, &iconFamily))
895 return NULL;
896 _err = RegisterIconRefFromIconFamily(creator,
897 iconType,
898 iconFamily,
899 &theIconRef);
900 if (_err != noErr) return PyMac_Error(_err);
901 _res = Py_BuildValue("O&",
902 ResObj_New, theIconRef);
903 return _res;
906 static PyObject *Icn_RegisterIconRefFromResource(PyObject *_self, PyObject *_args)
908 PyObject *_res = NULL;
909 OSErr _err;
910 OSType creator;
911 OSType iconType;
912 FSSpec resourceFile;
913 SInt16 resourceID;
914 IconRef theIconRef;
915 #ifndef RegisterIconRefFromResource
916 PyMac_PRECHECK(RegisterIconRefFromResource);
917 #endif
918 if (!PyArg_ParseTuple(_args, "O&O&O&h",
919 PyMac_GetOSType, &creator,
920 PyMac_GetOSType, &iconType,
921 PyMac_GetFSSpec, &resourceFile,
922 &resourceID))
923 return NULL;
924 _err = RegisterIconRefFromResource(creator,
925 iconType,
926 &resourceFile,
927 resourceID,
928 &theIconRef);
929 if (_err != noErr) return PyMac_Error(_err);
930 _res = Py_BuildValue("O&",
931 ResObj_New, theIconRef);
932 return _res;
935 static PyObject *Icn_UnregisterIconRef(PyObject *_self, PyObject *_args)
937 PyObject *_res = NULL;
938 OSErr _err;
939 OSType creator;
940 OSType iconType;
941 #ifndef UnregisterIconRef
942 PyMac_PRECHECK(UnregisterIconRef);
943 #endif
944 if (!PyArg_ParseTuple(_args, "O&O&",
945 PyMac_GetOSType, &creator,
946 PyMac_GetOSType, &iconType))
947 return NULL;
948 _err = UnregisterIconRef(creator,
949 iconType);
950 if (_err != noErr) return PyMac_Error(_err);
951 Py_INCREF(Py_None);
952 _res = Py_None;
953 return _res;
956 static PyObject *Icn_UpdateIconRef(PyObject *_self, PyObject *_args)
958 PyObject *_res = NULL;
959 OSErr _err;
960 IconRef theIconRef;
961 #ifndef UpdateIconRef
962 PyMac_PRECHECK(UpdateIconRef);
963 #endif
964 if (!PyArg_ParseTuple(_args, "O&",
965 ResObj_Convert, &theIconRef))
966 return NULL;
967 _err = UpdateIconRef(theIconRef);
968 if (_err != noErr) return PyMac_Error(_err);
969 Py_INCREF(Py_None);
970 _res = Py_None;
971 return _res;
974 static PyObject *Icn_OverrideIconRefFromResource(PyObject *_self, PyObject *_args)
976 PyObject *_res = NULL;
977 OSErr _err;
978 IconRef theIconRef;
979 FSSpec resourceFile;
980 SInt16 resourceID;
981 #ifndef OverrideIconRefFromResource
982 PyMac_PRECHECK(OverrideIconRefFromResource);
983 #endif
984 if (!PyArg_ParseTuple(_args, "O&O&h",
985 ResObj_Convert, &theIconRef,
986 PyMac_GetFSSpec, &resourceFile,
987 &resourceID))
988 return NULL;
989 _err = OverrideIconRefFromResource(theIconRef,
990 &resourceFile,
991 resourceID);
992 if (_err != noErr) return PyMac_Error(_err);
993 Py_INCREF(Py_None);
994 _res = Py_None;
995 return _res;
998 static PyObject *Icn_OverrideIconRef(PyObject *_self, PyObject *_args)
1000 PyObject *_res = NULL;
1001 OSErr _err;
1002 IconRef oldIconRef;
1003 IconRef newIconRef;
1004 #ifndef OverrideIconRef
1005 PyMac_PRECHECK(OverrideIconRef);
1006 #endif
1007 if (!PyArg_ParseTuple(_args, "O&O&",
1008 ResObj_Convert, &oldIconRef,
1009 ResObj_Convert, &newIconRef))
1010 return NULL;
1011 _err = OverrideIconRef(oldIconRef,
1012 newIconRef);
1013 if (_err != noErr) return PyMac_Error(_err);
1014 Py_INCREF(Py_None);
1015 _res = Py_None;
1016 return _res;
1019 static PyObject *Icn_RemoveIconRefOverride(PyObject *_self, PyObject *_args)
1021 PyObject *_res = NULL;
1022 OSErr _err;
1023 IconRef theIconRef;
1024 #ifndef RemoveIconRefOverride
1025 PyMac_PRECHECK(RemoveIconRefOverride);
1026 #endif
1027 if (!PyArg_ParseTuple(_args, "O&",
1028 ResObj_Convert, &theIconRef))
1029 return NULL;
1030 _err = RemoveIconRefOverride(theIconRef);
1031 if (_err != noErr) return PyMac_Error(_err);
1032 Py_INCREF(Py_None);
1033 _res = Py_None;
1034 return _res;
1037 static PyObject *Icn_CompositeIconRef(PyObject *_self, PyObject *_args)
1039 PyObject *_res = NULL;
1040 OSErr _err;
1041 IconRef backgroundIconRef;
1042 IconRef foregroundIconRef;
1043 IconRef compositeIconRef;
1044 #ifndef CompositeIconRef
1045 PyMac_PRECHECK(CompositeIconRef);
1046 #endif
1047 if (!PyArg_ParseTuple(_args, "O&O&",
1048 ResObj_Convert, &backgroundIconRef,
1049 ResObj_Convert, &foregroundIconRef))
1050 return NULL;
1051 _err = CompositeIconRef(backgroundIconRef,
1052 foregroundIconRef,
1053 &compositeIconRef);
1054 if (_err != noErr) return PyMac_Error(_err);
1055 _res = Py_BuildValue("O&",
1056 ResObj_New, compositeIconRef);
1057 return _res;
1060 static PyObject *Icn_IsIconRefComposite(PyObject *_self, PyObject *_args)
1062 PyObject *_res = NULL;
1063 OSErr _err;
1064 IconRef compositeIconRef;
1065 IconRef backgroundIconRef;
1066 IconRef foregroundIconRef;
1067 #ifndef IsIconRefComposite
1068 PyMac_PRECHECK(IsIconRefComposite);
1069 #endif
1070 if (!PyArg_ParseTuple(_args, "O&",
1071 ResObj_Convert, &compositeIconRef))
1072 return NULL;
1073 _err = IsIconRefComposite(compositeIconRef,
1074 &backgroundIconRef,
1075 &foregroundIconRef);
1076 if (_err != noErr) return PyMac_Error(_err);
1077 _res = Py_BuildValue("O&O&",
1078 ResObj_New, backgroundIconRef,
1079 ResObj_New, foregroundIconRef);
1080 return _res;
1083 static PyObject *Icn_IsValidIconRef(PyObject *_self, PyObject *_args)
1085 PyObject *_res = NULL;
1086 Boolean _rv;
1087 IconRef theIconRef;
1088 #ifndef IsValidIconRef
1089 PyMac_PRECHECK(IsValidIconRef);
1090 #endif
1091 if (!PyArg_ParseTuple(_args, "O&",
1092 ResObj_Convert, &theIconRef))
1093 return NULL;
1094 _rv = IsValidIconRef(theIconRef);
1095 _res = Py_BuildValue("b",
1096 _rv);
1097 return _res;
1100 static PyObject *Icn_PlotIconRef(PyObject *_self, PyObject *_args)
1102 PyObject *_res = NULL;
1103 OSErr _err;
1104 Rect theRect;
1105 IconAlignmentType align;
1106 IconTransformType transform;
1107 IconServicesUsageFlags theIconServicesUsageFlags;
1108 IconRef theIconRef;
1109 #ifndef PlotIconRef
1110 PyMac_PRECHECK(PlotIconRef);
1111 #endif
1112 if (!PyArg_ParseTuple(_args, "O&hhlO&",
1113 PyMac_GetRect, &theRect,
1114 &align,
1115 &transform,
1116 &theIconServicesUsageFlags,
1117 ResObj_Convert, &theIconRef))
1118 return NULL;
1119 _err = PlotIconRef(&theRect,
1120 align,
1121 transform,
1122 theIconServicesUsageFlags,
1123 theIconRef);
1124 if (_err != noErr) return PyMac_Error(_err);
1125 Py_INCREF(Py_None);
1126 _res = Py_None;
1127 return _res;
1130 static PyObject *Icn_PtInIconRef(PyObject *_self, PyObject *_args)
1132 PyObject *_res = NULL;
1133 Boolean _rv;
1134 Point testPt;
1135 Rect iconRect;
1136 IconAlignmentType align;
1137 IconServicesUsageFlags theIconServicesUsageFlags;
1138 IconRef theIconRef;
1139 #ifndef PtInIconRef
1140 PyMac_PRECHECK(PtInIconRef);
1141 #endif
1142 if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1143 PyMac_GetPoint, &testPt,
1144 PyMac_GetRect, &iconRect,
1145 &align,
1146 &theIconServicesUsageFlags,
1147 ResObj_Convert, &theIconRef))
1148 return NULL;
1149 _rv = PtInIconRef(&testPt,
1150 &iconRect,
1151 align,
1152 theIconServicesUsageFlags,
1153 theIconRef);
1154 _res = Py_BuildValue("b",
1155 _rv);
1156 return _res;
1159 static PyObject *Icn_RectInIconRef(PyObject *_self, PyObject *_args)
1161 PyObject *_res = NULL;
1162 Boolean _rv;
1163 Rect testRect;
1164 Rect iconRect;
1165 IconAlignmentType align;
1166 IconServicesUsageFlags iconServicesUsageFlags;
1167 IconRef theIconRef;
1168 #ifndef RectInIconRef
1169 PyMac_PRECHECK(RectInIconRef);
1170 #endif
1171 if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1172 PyMac_GetRect, &testRect,
1173 PyMac_GetRect, &iconRect,
1174 &align,
1175 &iconServicesUsageFlags,
1176 ResObj_Convert, &theIconRef))
1177 return NULL;
1178 _rv = RectInIconRef(&testRect,
1179 &iconRect,
1180 align,
1181 iconServicesUsageFlags,
1182 theIconRef);
1183 _res = Py_BuildValue("b",
1184 _rv);
1185 return _res;
1188 static PyObject *Icn_IconRefToRgn(PyObject *_self, PyObject *_args)
1190 PyObject *_res = NULL;
1191 OSErr _err;
1192 RgnHandle theRgn;
1193 Rect iconRect;
1194 IconAlignmentType align;
1195 IconServicesUsageFlags iconServicesUsageFlags;
1196 IconRef theIconRef;
1197 #ifndef IconRefToRgn
1198 PyMac_PRECHECK(IconRefToRgn);
1199 #endif
1200 if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1201 ResObj_Convert, &theRgn,
1202 PyMac_GetRect, &iconRect,
1203 &align,
1204 &iconServicesUsageFlags,
1205 ResObj_Convert, &theIconRef))
1206 return NULL;
1207 _err = IconRefToRgn(theRgn,
1208 &iconRect,
1209 align,
1210 iconServicesUsageFlags,
1211 theIconRef);
1212 if (_err != noErr) return PyMac_Error(_err);
1213 Py_INCREF(Py_None);
1214 _res = Py_None;
1215 return _res;
1218 static PyObject *Icn_GetIconSizesFromIconRef(PyObject *_self, PyObject *_args)
1220 PyObject *_res = NULL;
1221 OSErr _err;
1222 IconSelectorValue iconSelectorInput;
1223 IconSelectorValue iconSelectorOutputPtr;
1224 IconServicesUsageFlags iconServicesUsageFlags;
1225 IconRef theIconRef;
1226 #ifndef GetIconSizesFromIconRef
1227 PyMac_PRECHECK(GetIconSizesFromIconRef);
1228 #endif
1229 if (!PyArg_ParseTuple(_args, "llO&",
1230 &iconSelectorInput,
1231 &iconServicesUsageFlags,
1232 ResObj_Convert, &theIconRef))
1233 return NULL;
1234 _err = GetIconSizesFromIconRef(iconSelectorInput,
1235 &iconSelectorOutputPtr,
1236 iconServicesUsageFlags,
1237 theIconRef);
1238 if (_err != noErr) return PyMac_Error(_err);
1239 _res = Py_BuildValue("l",
1240 iconSelectorOutputPtr);
1241 return _res;
1244 static PyObject *Icn_FlushIconRefs(PyObject *_self, PyObject *_args)
1246 PyObject *_res = NULL;
1247 OSErr _err;
1248 OSType creator;
1249 OSType iconType;
1250 #ifndef FlushIconRefs
1251 PyMac_PRECHECK(FlushIconRefs);
1252 #endif
1253 if (!PyArg_ParseTuple(_args, "O&O&",
1254 PyMac_GetOSType, &creator,
1255 PyMac_GetOSType, &iconType))
1256 return NULL;
1257 _err = FlushIconRefs(creator,
1258 iconType);
1259 if (_err != noErr) return PyMac_Error(_err);
1260 Py_INCREF(Py_None);
1261 _res = Py_None;
1262 return _res;
1265 static PyObject *Icn_FlushIconRefsByVolume(PyObject *_self, PyObject *_args)
1267 PyObject *_res = NULL;
1268 OSErr _err;
1269 SInt16 vRefNum;
1270 #ifndef FlushIconRefsByVolume
1271 PyMac_PRECHECK(FlushIconRefsByVolume);
1272 #endif
1273 if (!PyArg_ParseTuple(_args, "h",
1274 &vRefNum))
1275 return NULL;
1276 _err = FlushIconRefsByVolume(vRefNum);
1277 if (_err != noErr) return PyMac_Error(_err);
1278 Py_INCREF(Py_None);
1279 _res = Py_None;
1280 return _res;
1283 static PyObject *Icn_SetCustomIconsEnabled(PyObject *_self, PyObject *_args)
1285 PyObject *_res = NULL;
1286 OSErr _err;
1287 SInt16 vRefNum;
1288 Boolean enableCustomIcons;
1289 #ifndef SetCustomIconsEnabled
1290 PyMac_PRECHECK(SetCustomIconsEnabled);
1291 #endif
1292 if (!PyArg_ParseTuple(_args, "hb",
1293 &vRefNum,
1294 &enableCustomIcons))
1295 return NULL;
1296 _err = SetCustomIconsEnabled(vRefNum,
1297 enableCustomIcons);
1298 if (_err != noErr) return PyMac_Error(_err);
1299 Py_INCREF(Py_None);
1300 _res = Py_None;
1301 return _res;
1304 static PyObject *Icn_GetCustomIconsEnabled(PyObject *_self, PyObject *_args)
1306 PyObject *_res = NULL;
1307 OSErr _err;
1308 SInt16 vRefNum;
1309 Boolean customIconsEnabled;
1310 #ifndef GetCustomIconsEnabled
1311 PyMac_PRECHECK(GetCustomIconsEnabled);
1312 #endif
1313 if (!PyArg_ParseTuple(_args, "h",
1314 &vRefNum))
1315 return NULL;
1316 _err = GetCustomIconsEnabled(vRefNum,
1317 &customIconsEnabled);
1318 if (_err != noErr) return PyMac_Error(_err);
1319 _res = Py_BuildValue("b",
1320 customIconsEnabled);
1321 return _res;
1324 static PyObject *Icn_IsIconRefMaskEmpty(PyObject *_self, PyObject *_args)
1326 PyObject *_res = NULL;
1327 Boolean _rv;
1328 IconRef iconRef;
1329 #ifndef IsIconRefMaskEmpty
1330 PyMac_PRECHECK(IsIconRefMaskEmpty);
1331 #endif
1332 if (!PyArg_ParseTuple(_args, "O&",
1333 ResObj_Convert, &iconRef))
1334 return NULL;
1335 _rv = IsIconRefMaskEmpty(iconRef);
1336 _res = Py_BuildValue("b",
1337 _rv);
1338 return _res;
1341 #if TARGET_API_MAC_CARBON
1343 static PyObject *Icn_GetIconRefVariant(PyObject *_self, PyObject *_args)
1345 PyObject *_res = NULL;
1346 IconRef _rv;
1347 IconRef inIconRef;
1348 OSType inVariant;
1349 IconTransformType outTransform;
1350 #ifndef GetIconRefVariant
1351 PyMac_PRECHECK(GetIconRefVariant);
1352 #endif
1353 if (!PyArg_ParseTuple(_args, "O&O&",
1354 ResObj_Convert, &inIconRef,
1355 PyMac_GetOSType, &inVariant))
1356 return NULL;
1357 _rv = GetIconRefVariant(inIconRef,
1358 inVariant,
1359 &outTransform);
1360 _res = Py_BuildValue("O&h",
1361 ResObj_New, _rv,
1362 outTransform);
1363 return _res;
1365 #endif
1367 #if TARGET_API_MAC_CARBON
1369 static PyObject *Icn_RegisterIconRefFromIconFile(PyObject *_self, PyObject *_args)
1371 PyObject *_res = NULL;
1372 OSErr _err;
1373 OSType creator;
1374 OSType iconType;
1375 FSSpec iconFile;
1376 IconRef theIconRef;
1377 #ifndef RegisterIconRefFromIconFile
1378 PyMac_PRECHECK(RegisterIconRefFromIconFile);
1379 #endif
1380 if (!PyArg_ParseTuple(_args, "O&O&O&",
1381 PyMac_GetOSType, &creator,
1382 PyMac_GetOSType, &iconType,
1383 PyMac_GetFSSpec, &iconFile))
1384 return NULL;
1385 _err = RegisterIconRefFromIconFile(creator,
1386 iconType,
1387 &iconFile,
1388 &theIconRef);
1389 if (_err != noErr) return PyMac_Error(_err);
1390 _res = Py_BuildValue("O&",
1391 ResObj_New, theIconRef);
1392 return _res;
1394 #endif
1396 #if TARGET_API_MAC_CARBON
1398 static PyObject *Icn_ReadIconFile(PyObject *_self, PyObject *_args)
1400 PyObject *_res = NULL;
1401 OSErr _err;
1402 FSSpec iconFile;
1403 IconFamilyHandle iconFamily;
1404 #ifndef ReadIconFile
1405 PyMac_PRECHECK(ReadIconFile);
1406 #endif
1407 if (!PyArg_ParseTuple(_args, "O&",
1408 PyMac_GetFSSpec, &iconFile))
1409 return NULL;
1410 _err = ReadIconFile(&iconFile,
1411 &iconFamily);
1412 if (_err != noErr) return PyMac_Error(_err);
1413 _res = Py_BuildValue("O&",
1414 ResObj_New, iconFamily);
1415 return _res;
1417 #endif
1419 #if TARGET_API_MAC_CARBON
1421 static PyObject *Icn_WriteIconFile(PyObject *_self, PyObject *_args)
1423 PyObject *_res = NULL;
1424 OSErr _err;
1425 IconFamilyHandle iconFamily;
1426 FSSpec iconFile;
1427 #ifndef WriteIconFile
1428 PyMac_PRECHECK(WriteIconFile);
1429 #endif
1430 if (!PyArg_ParseTuple(_args, "O&O&",
1431 ResObj_Convert, &iconFamily,
1432 PyMac_GetFSSpec, &iconFile))
1433 return NULL;
1434 _err = WriteIconFile(iconFamily,
1435 &iconFile);
1436 if (_err != noErr) return PyMac_Error(_err);
1437 Py_INCREF(Py_None);
1438 _res = Py_None;
1439 return _res;
1441 #endif
1443 static PyMethodDef Icn_methods[] = {
1444 {"GetCIcon", (PyCFunction)Icn_GetCIcon, 1,
1445 "(SInt16 iconID) -> (CIconHandle _rv)"},
1446 {"PlotCIcon", (PyCFunction)Icn_PlotCIcon, 1,
1447 "(Rect theRect, CIconHandle theIcon) -> None"},
1448 {"DisposeCIcon", (PyCFunction)Icn_DisposeCIcon, 1,
1449 "(CIconHandle theIcon) -> None"},
1450 {"GetIcon", (PyCFunction)Icn_GetIcon, 1,
1451 "(SInt16 iconID) -> (Handle _rv)"},
1452 {"PlotIcon", (PyCFunction)Icn_PlotIcon, 1,
1453 "(Rect theRect, Handle theIcon) -> None"},
1454 {"PlotIconID", (PyCFunction)Icn_PlotIconID, 1,
1455 "(Rect theRect, IconAlignmentType align, IconTransformType transform, SInt16 theResID) -> None"},
1456 {"NewIconSuite", (PyCFunction)Icn_NewIconSuite, 1,
1457 "() -> (IconSuiteRef theIconSuite)"},
1458 {"AddIconToSuite", (PyCFunction)Icn_AddIconToSuite, 1,
1459 "(Handle theIconData, IconSuiteRef theSuite, ResType theType) -> None"},
1460 {"GetIconFromSuite", (PyCFunction)Icn_GetIconFromSuite, 1,
1461 "(IconSuiteRef theSuite, ResType theType) -> (Handle theIconData)"},
1462 {"GetIconSuite", (PyCFunction)Icn_GetIconSuite, 1,
1463 "(SInt16 theResID, IconSelectorValue selector) -> (IconSuiteRef theIconSuite)"},
1464 {"DisposeIconSuite", (PyCFunction)Icn_DisposeIconSuite, 1,
1465 "(IconSuiteRef theIconSuite, Boolean disposeData) -> None"},
1466 {"PlotIconSuite", (PyCFunction)Icn_PlotIconSuite, 1,
1467 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconSuiteRef theIconSuite) -> None"},
1468 {"LoadIconCache", (PyCFunction)Icn_LoadIconCache, 1,
1469 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconCacheRef theIconCache) -> None"},
1470 {"GetLabel", (PyCFunction)Icn_GetLabel, 1,
1471 "(SInt16 labelNumber, Str255 labelString) -> (RGBColor labelColor)"},
1472 {"PtInIconID", (PyCFunction)Icn_PtInIconID, 1,
1473 "(Point testPt, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)"},
1474 {"PtInIconSuite", (PyCFunction)Icn_PtInIconSuite, 1,
1475 "(Point testPt, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)"},
1476 {"RectInIconID", (PyCFunction)Icn_RectInIconID, 1,
1477 "(Rect testRect, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)"},
1478 {"RectInIconSuite", (PyCFunction)Icn_RectInIconSuite, 1,
1479 "(Rect testRect, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)"},
1480 {"IconIDToRgn", (PyCFunction)Icn_IconIDToRgn, 1,
1481 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> None"},
1482 {"IconSuiteToRgn", (PyCFunction)Icn_IconSuiteToRgn, 1,
1483 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> None"},
1484 {"SetSuiteLabel", (PyCFunction)Icn_SetSuiteLabel, 1,
1485 "(IconSuiteRef theSuite, SInt16 theLabel) -> None"},
1486 {"GetSuiteLabel", (PyCFunction)Icn_GetSuiteLabel, 1,
1487 "(IconSuiteRef theSuite) -> (SInt16 _rv)"},
1488 {"PlotIconHandle", (PyCFunction)Icn_PlotIconHandle, 1,
1489 "(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theIcon) -> None"},
1490 {"PlotSICNHandle", (PyCFunction)Icn_PlotSICNHandle, 1,
1491 "(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theSICN) -> None"},
1492 {"PlotCIconHandle", (PyCFunction)Icn_PlotCIconHandle, 1,
1493 "(Rect theRect, IconAlignmentType align, IconTransformType transform, CIconHandle theCIcon) -> None"},
1495 #if !TARGET_API_MAC_CARBON
1496 {"IconServicesTerminate", (PyCFunction)Icn_IconServicesTerminate, 1,
1497 "() -> None"},
1498 #endif
1499 {"IconRefToIconFamily", (PyCFunction)Icn_IconRefToIconFamily, 1,
1500 "(IconRef theIconRef, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)"},
1501 {"IconFamilyToIconSuite", (PyCFunction)Icn_IconFamilyToIconSuite, 1,
1502 "(IconFamilyHandle iconFamily, IconSelectorValue whichIcons) -> (IconSuiteRef iconSuite)"},
1503 {"IconSuiteToIconFamily", (PyCFunction)Icn_IconSuiteToIconFamily, 1,
1504 "(IconSuiteRef iconSuite, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)"},
1505 {"SetIconFamilyData", (PyCFunction)Icn_SetIconFamilyData, 1,
1506 "(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None"},
1507 {"GetIconFamilyData", (PyCFunction)Icn_GetIconFamilyData, 1,
1508 "(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None"},
1509 {"GetIconRefOwners", (PyCFunction)Icn_GetIconRefOwners, 1,
1510 "(IconRef theIconRef) -> (UInt16 owners)"},
1511 {"AcquireIconRef", (PyCFunction)Icn_AcquireIconRef, 1,
1512 "(IconRef theIconRef) -> None"},
1513 {"ReleaseIconRef", (PyCFunction)Icn_ReleaseIconRef, 1,
1514 "(IconRef theIconRef) -> None"},
1515 {"GetIconRefFromFile", (PyCFunction)Icn_GetIconRefFromFile, 1,
1516 "(FSSpec theFile) -> (IconRef theIconRef, SInt16 theLabel)"},
1517 {"GetIconRef", (PyCFunction)Icn_GetIconRef, 1,
1518 "(SInt16 vRefNum, OSType creator, OSType iconType) -> (IconRef theIconRef)"},
1519 {"GetIconRefFromFolder", (PyCFunction)Icn_GetIconRefFromFolder, 1,
1520 "(SInt16 vRefNum, SInt32 parentFolderID, SInt32 folderID, SInt8 attributes, SInt8 accessPrivileges) -> (IconRef theIconRef)"},
1521 {"RegisterIconRefFromIconFamily", (PyCFunction)Icn_RegisterIconRefFromIconFamily, 1,
1522 "(OSType creator, OSType iconType, IconFamilyHandle iconFamily) -> (IconRef theIconRef)"},
1523 {"RegisterIconRefFromResource", (PyCFunction)Icn_RegisterIconRefFromResource, 1,
1524 "(OSType creator, OSType iconType, FSSpec resourceFile, SInt16 resourceID) -> (IconRef theIconRef)"},
1525 {"UnregisterIconRef", (PyCFunction)Icn_UnregisterIconRef, 1,
1526 "(OSType creator, OSType iconType) -> None"},
1527 {"UpdateIconRef", (PyCFunction)Icn_UpdateIconRef, 1,
1528 "(IconRef theIconRef) -> None"},
1529 {"OverrideIconRefFromResource", (PyCFunction)Icn_OverrideIconRefFromResource, 1,
1530 "(IconRef theIconRef, FSSpec resourceFile, SInt16 resourceID) -> None"},
1531 {"OverrideIconRef", (PyCFunction)Icn_OverrideIconRef, 1,
1532 "(IconRef oldIconRef, IconRef newIconRef) -> None"},
1533 {"RemoveIconRefOverride", (PyCFunction)Icn_RemoveIconRefOverride, 1,
1534 "(IconRef theIconRef) -> None"},
1535 {"CompositeIconRef", (PyCFunction)Icn_CompositeIconRef, 1,
1536 "(IconRef backgroundIconRef, IconRef foregroundIconRef) -> (IconRef compositeIconRef)"},
1537 {"IsIconRefComposite", (PyCFunction)Icn_IsIconRefComposite, 1,
1538 "(IconRef compositeIconRef) -> (IconRef backgroundIconRef, IconRef foregroundIconRef)"},
1539 {"IsValidIconRef", (PyCFunction)Icn_IsValidIconRef, 1,
1540 "(IconRef theIconRef) -> (Boolean _rv)"},
1541 {"PlotIconRef", (PyCFunction)Icn_PlotIconRef, 1,
1542 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> None"},
1543 {"PtInIconRef", (PyCFunction)Icn_PtInIconRef, 1,
1544 "(Point testPt, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)"},
1545 {"RectInIconRef", (PyCFunction)Icn_RectInIconRef, 1,
1546 "(Rect testRect, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)"},
1547 {"IconRefToRgn", (PyCFunction)Icn_IconRefToRgn, 1,
1548 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> None"},
1549 {"GetIconSizesFromIconRef", (PyCFunction)Icn_GetIconSizesFromIconRef, 1,
1550 "(IconSelectorValue iconSelectorInput, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (IconSelectorValue iconSelectorOutputPtr)"},
1551 {"FlushIconRefs", (PyCFunction)Icn_FlushIconRefs, 1,
1552 "(OSType creator, OSType iconType) -> None"},
1553 {"FlushIconRefsByVolume", (PyCFunction)Icn_FlushIconRefsByVolume, 1,
1554 "(SInt16 vRefNum) -> None"},
1555 {"SetCustomIconsEnabled", (PyCFunction)Icn_SetCustomIconsEnabled, 1,
1556 "(SInt16 vRefNum, Boolean enableCustomIcons) -> None"},
1557 {"GetCustomIconsEnabled", (PyCFunction)Icn_GetCustomIconsEnabled, 1,
1558 "(SInt16 vRefNum) -> (Boolean customIconsEnabled)"},
1559 {"IsIconRefMaskEmpty", (PyCFunction)Icn_IsIconRefMaskEmpty, 1,
1560 "(IconRef iconRef) -> (Boolean _rv)"},
1562 #if TARGET_API_MAC_CARBON
1563 {"GetIconRefVariant", (PyCFunction)Icn_GetIconRefVariant, 1,
1564 "(IconRef inIconRef, OSType inVariant) -> (IconRef _rv, IconTransformType outTransform)"},
1565 #endif
1567 #if TARGET_API_MAC_CARBON
1568 {"RegisterIconRefFromIconFile", (PyCFunction)Icn_RegisterIconRefFromIconFile, 1,
1569 "(OSType creator, OSType iconType, FSSpec iconFile) -> (IconRef theIconRef)"},
1570 #endif
1572 #if TARGET_API_MAC_CARBON
1573 {"ReadIconFile", (PyCFunction)Icn_ReadIconFile, 1,
1574 "(FSSpec iconFile) -> (IconFamilyHandle iconFamily)"},
1575 #endif
1577 #if TARGET_API_MAC_CARBON
1578 {"WriteIconFile", (PyCFunction)Icn_WriteIconFile, 1,
1579 "(IconFamilyHandle iconFamily, FSSpec iconFile) -> None"},
1580 #endif
1581 {NULL, NULL, 0}
1587 void init_Icn(void)
1589 PyObject *m;
1590 PyObject *d;
1595 m = Py_InitModule("_Icn", Icn_methods);
1596 d = PyModule_GetDict(m);
1597 Icn_Error = PyMac_GetOSErrException();
1598 if (Icn_Error == NULL ||
1599 PyDict_SetItemString(d, "Error", Icn_Error) != 0)
1600 return;
1603 /* ======================== End module _Icn ========================= */