ยปCore Development>Code coverage>Mac/Modules/icn/_Icnmodule.c

Python code coverage for Mac/Modules/icn/_Icnmodule.c

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