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 PyMethodDef Icn_methods
[] = {
608 {"GetCIcon", (PyCFunction
)Icn_GetCIcon
, 1,
609 "(SInt16 iconID) -> (CIconHandle _rv)"},
610 {"PlotCIcon", (PyCFunction
)Icn_PlotCIcon
, 1,
611 "(Rect theRect, CIconHandle theIcon) -> None"},
612 {"DisposeCIcon", (PyCFunction
)Icn_DisposeCIcon
, 1,
613 "(CIconHandle theIcon) -> None"},
614 {"GetIcon", (PyCFunction
)Icn_GetIcon
, 1,
615 "(SInt16 iconID) -> (Handle _rv)"},
616 {"PlotIcon", (PyCFunction
)Icn_PlotIcon
, 1,
617 "(Rect theRect, Handle theIcon) -> None"},
618 {"PlotIconID", (PyCFunction
)Icn_PlotIconID
, 1,
619 "(Rect theRect, IconAlignmentType align, IconTransformType transform, SInt16 theResID) -> None"},
620 {"NewIconSuite", (PyCFunction
)Icn_NewIconSuite
, 1,
621 "() -> (IconSuiteRef theIconSuite)"},
622 {"AddIconToSuite", (PyCFunction
)Icn_AddIconToSuite
, 1,
623 "(Handle theIconData, IconSuiteRef theSuite, ResType theType) -> None"},
624 {"GetIconFromSuite", (PyCFunction
)Icn_GetIconFromSuite
, 1,
625 "(IconSuiteRef theSuite, ResType theType) -> (Handle theIconData)"},
626 {"GetIconSuite", (PyCFunction
)Icn_GetIconSuite
, 1,
627 "(SInt16 theResID, IconSelectorValue selector) -> (IconSuiteRef theIconSuite)"},
628 {"DisposeIconSuite", (PyCFunction
)Icn_DisposeIconSuite
, 1,
629 "(IconSuiteRef theIconSuite, Boolean disposeData) -> None"},
630 {"PlotIconSuite", (PyCFunction
)Icn_PlotIconSuite
, 1,
631 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconSuiteRef theIconSuite) -> None"},
632 {"LoadIconCache", (PyCFunction
)Icn_LoadIconCache
, 1,
633 "(Rect theRect, IconAlignmentType align, IconTransformType transform, IconCacheRef theIconCache) -> None"},
634 {"GetLabel", (PyCFunction
)Icn_GetLabel
, 1,
635 "(SInt16 labelNumber, Str255 labelString) -> (RGBColor labelColor)"},
636 {"PtInIconID", (PyCFunction
)Icn_PtInIconID
, 1,
637 "(Point testPt, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)"},
638 {"PtInIconSuite", (PyCFunction
)Icn_PtInIconSuite
, 1,
639 "(Point testPt, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)"},
640 {"RectInIconID", (PyCFunction
)Icn_RectInIconID
, 1,
641 "(Rect testRect, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)"},
642 {"RectInIconSuite", (PyCFunction
)Icn_RectInIconSuite
, 1,
643 "(Rect testRect, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)"},
644 {"IconIDToRgn", (PyCFunction
)Icn_IconIDToRgn
, 1,
645 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> None"},
646 {"IconSuiteToRgn", (PyCFunction
)Icn_IconSuiteToRgn
, 1,
647 "(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> None"},
648 {"SetSuiteLabel", (PyCFunction
)Icn_SetSuiteLabel
, 1,
649 "(IconSuiteRef theSuite, SInt16 theLabel) -> None"},
650 {"GetSuiteLabel", (PyCFunction
)Icn_GetSuiteLabel
, 1,
651 "(IconSuiteRef theSuite) -> (SInt16 _rv)"},
652 {"PlotIconHandle", (PyCFunction
)Icn_PlotIconHandle
, 1,
653 "(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theIcon) -> None"},
654 {"PlotSICNHandle", (PyCFunction
)Icn_PlotSICNHandle
, 1,
655 "(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theSICN) -> None"},
656 {"PlotCIconHandle", (PyCFunction
)Icn_PlotCIconHandle
, 1,
657 "(Rect theRect, IconAlignmentType align, IconTransformType transform, CIconHandle theCIcon) -> None"},
672 m
= Py_InitModule("Icn", Icn_methods
);
673 d
= PyModule_GetDict(m
);
674 Icn_Error
= PyMac_GetOSErrException();
675 if (Icn_Error
== NULL
||
676 PyDict_SetItemString(d
, "Error", Icn_Error
) != 0)
677 Py_FatalError("can't initialize Icn.Error");
680 /* ========================= End module Icn ========================= */