2 /* ========================== Module List =========================== */
8 #define SystemSevenOrLater 1
16 extern PyObject
*ResObj_New(Handle
);
17 extern PyObject
*ResObj_OptNew(Handle
);
18 extern int ResObj_Convert(PyObject
*, Handle
*);
20 extern PyObject
*WinObj_New(WindowPtr
);
21 extern int WinObj_Convert(PyObject
*, WindowPtr
*);
23 extern PyObject
*DlgObj_New(DialogPtr
);
24 extern int DlgObj_Convert(PyObject
*, DialogPtr
*);
25 extern PyTypeObject Dialog_Type
;
26 #define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
28 extern PyObject
*MenuObj_New(MenuHandle
);
29 extern int MenuObj_Convert(PyObject
*, MenuHandle
*);
31 extern PyObject
*CtlObj_New(ControlHandle
);
32 extern int CtlObj_Convert(PyObject
*, ControlHandle
*);
34 extern PyObject
*WinObj_WhichWindow(WindowPtr
);
38 static PyObject
*List_Error
;
40 /* ------------------------ Object type List ------------------------ */
42 PyTypeObject List_Type
;
44 #define ListObj_Check(x) ((x)->ob_type == &List_Type)
46 typedef struct ListObject
{
51 PyObject
*ListObj_New(itself
)
56 PyErr_SetString(List_Error
,"Cannot create null List");
59 it
= PyObject_NEW(ListObject
, &List_Type
);
60 if (it
== NULL
) return NULL
;
61 it
->ob_itself
= itself
;
62 return (PyObject
*)it
;
64 ListObj_Convert(v
, p_itself
)
68 if (!ListObj_Check(v
))
70 PyErr_SetString(PyExc_TypeError
, "List required");
73 *p_itself
= ((ListObject
*)v
)->ob_itself
;
77 static void ListObj_dealloc(self
)
80 LDispose(self
->ob_itself
);
84 static PyObject
*ListObj_LAddColumn(_self
, _args
)
88 PyObject
*_res
= NULL
;
92 if (!PyArg_ParseTuple(_args
, "hh",
96 _rv
= LAddColumn(count
,
99 _res
= Py_BuildValue("h",
104 static PyObject
*ListObj_LAddRow(_self
, _args
)
108 PyObject
*_res
= NULL
;
112 if (!PyArg_ParseTuple(_args
, "hh",
119 _res
= Py_BuildValue("h",
124 static PyObject
*ListObj_LDelColumn(_self
, _args
)
128 PyObject
*_res
= NULL
;
131 if (!PyArg_ParseTuple(_args
, "hh",
143 static PyObject
*ListObj_LDelRow(_self
, _args
)
147 PyObject
*_res
= NULL
;
150 if (!PyArg_ParseTuple(_args
, "hh",
162 static PyObject
*ListObj_LGetSelect(_self
, _args
)
166 PyObject
*_res
= NULL
;
170 if (!PyArg_ParseTuple(_args
, "bO&",
172 PyMac_GetPoint
, &theCell
))
174 _rv
= LGetSelect(next
,
177 _res
= Py_BuildValue("bO&",
179 PyMac_BuildPoint
, theCell
);
183 static PyObject
*ListObj_LLastClick(_self
, _args
)
187 PyObject
*_res
= NULL
;
189 if (!PyArg_ParseTuple(_args
, ""))
191 _rv
= LLastClick(_self
->ob_itself
);
192 _res
= Py_BuildValue("O&",
193 PyMac_BuildPoint
, _rv
);
197 static PyObject
*ListObj_LNextCell(_self
, _args
)
201 PyObject
*_res
= NULL
;
206 if (!PyArg_ParseTuple(_args
, "bbO&",
209 PyMac_GetPoint
, &theCell
))
211 _rv
= LNextCell(hNext
,
215 _res
= Py_BuildValue("bO&",
217 PyMac_BuildPoint
, theCell
);
221 static PyObject
*ListObj_LSize(_self
, _args
)
225 PyObject
*_res
= NULL
;
228 if (!PyArg_ParseTuple(_args
, "hh",
240 static PyObject
*ListObj_LSetDrawingMode(_self
, _args
)
244 PyObject
*_res
= NULL
;
246 if (!PyArg_ParseTuple(_args
, "b",
249 LSetDrawingMode(drawIt
,
256 static PyObject
*ListObj_LScroll(_self
, _args
)
260 PyObject
*_res
= NULL
;
263 if (!PyArg_ParseTuple(_args
, "hh",
275 static PyObject
*ListObj_LAutoScroll(_self
, _args
)
279 PyObject
*_res
= NULL
;
280 if (!PyArg_ParseTuple(_args
, ""))
282 LAutoScroll(_self
->ob_itself
);
288 static PyObject
*ListObj_LUpdate(_self
, _args
)
292 PyObject
*_res
= NULL
;
293 if (!PyArg_ParseTuple(_args
, ""))
295 LUpdate((*_self
->ob_itself
)->port
->visRgn
,
302 static PyObject
*ListObj_LActivate(_self
, _args
)
306 PyObject
*_res
= NULL
;
308 if (!PyArg_ParseTuple(_args
, "b",
318 static PyObject
*ListObj_LCellSize(_self
, _args
)
322 PyObject
*_res
= NULL
;
324 if (!PyArg_ParseTuple(_args
, "O&",
325 PyMac_GetPoint
, &cSize
))
334 static PyObject
*ListObj_LClick(_self
, _args
)
338 PyObject
*_res
= NULL
;
342 if (!PyArg_ParseTuple(_args
, "O&h",
349 _res
= Py_BuildValue("b",
354 static PyObject
*ListObj_LAddToCell(_self
, _args
)
358 PyObject
*_res
= NULL
;
360 short dataPtr__len__
;
361 int dataPtr__in_len__
;
363 if (!PyArg_ParseTuple(_args
, "s#O&",
364 &dataPtr__in__
, &dataPtr__in_len__
,
365 PyMac_GetPoint
, &theCell
))
367 dataPtr__len__
= dataPtr__in_len__
;
368 LAddToCell(dataPtr__in__
, dataPtr__len__
,
377 static PyObject
*ListObj_LClrCell(_self
, _args
)
381 PyObject
*_res
= NULL
;
383 if (!PyArg_ParseTuple(_args
, "O&",
384 PyMac_GetPoint
, &theCell
))
393 static PyObject
*ListObj_LGetCell(_self
, _args
)
397 PyObject
*_res
= NULL
;
398 char *dataPtr__out__
;
399 short dataPtr__len__
;
400 int dataPtr__in_len__
;
402 if (!PyArg_ParseTuple(_args
, "iO&",
404 PyMac_GetPoint
, &theCell
))
406 if ((dataPtr__out__
= malloc(dataPtr__in_len__
)) == NULL
)
409 goto dataPtr__error__
;
411 dataPtr__len__
= dataPtr__in_len__
;
412 LGetCell(dataPtr__out__
, &dataPtr__len__
,
415 _res
= Py_BuildValue("s#",
416 dataPtr__out__
, (int)dataPtr__len__
);
417 free(dataPtr__out__
);
422 static PyObject
*ListObj_LRect(_self
, _args
)
426 PyObject
*_res
= NULL
;
429 if (!PyArg_ParseTuple(_args
, "O&",
430 PyMac_GetPoint
, &theCell
))
435 _res
= Py_BuildValue("O&",
436 PyMac_BuildRect
, &cellRect
);
440 static PyObject
*ListObj_LSetCell(_self
, _args
)
444 PyObject
*_res
= NULL
;
446 short dataPtr__len__
;
447 int dataPtr__in_len__
;
449 if (!PyArg_ParseTuple(_args
, "s#O&",
450 &dataPtr__in__
, &dataPtr__in_len__
,
451 PyMac_GetPoint
, &theCell
))
453 dataPtr__len__
= dataPtr__in_len__
;
454 LSetCell(dataPtr__in__
, dataPtr__len__
,
463 static PyObject
*ListObj_LSetSelect(_self
, _args
)
467 PyObject
*_res
= NULL
;
470 if (!PyArg_ParseTuple(_args
, "bO&",
472 PyMac_GetPoint
, &theCell
))
482 static PyObject
*ListObj_LDraw(_self
, _args
)
486 PyObject
*_res
= NULL
;
488 if (!PyArg_ParseTuple(_args
, "O&",
489 PyMac_GetPoint
, &theCell
))
498 static PyMethodDef ListObj_methods
[] = {
499 {"LAddColumn", (PyCFunction
)ListObj_LAddColumn
, 1,
500 "(short count, short colNum) -> (short _rv)"},
501 {"LAddRow", (PyCFunction
)ListObj_LAddRow
, 1,
502 "(short count, short rowNum) -> (short _rv)"},
503 {"LDelColumn", (PyCFunction
)ListObj_LDelColumn
, 1,
504 "(short count, short colNum) -> None"},
505 {"LDelRow", (PyCFunction
)ListObj_LDelRow
, 1,
506 "(short count, short rowNum) -> None"},
507 {"LGetSelect", (PyCFunction
)ListObj_LGetSelect
, 1,
508 "(Boolean next, Point theCell) -> (Boolean _rv, Point theCell)"},
509 {"LLastClick", (PyCFunction
)ListObj_LLastClick
, 1,
510 "() -> (Point _rv)"},
511 {"LNextCell", (PyCFunction
)ListObj_LNextCell
, 1,
512 "(Boolean hNext, Boolean vNext, Point theCell) -> (Boolean _rv, Point theCell)"},
513 {"LSize", (PyCFunction
)ListObj_LSize
, 1,
514 "(short listWidth, short listHeight) -> None"},
515 {"LSetDrawingMode", (PyCFunction
)ListObj_LSetDrawingMode
, 1,
516 "(Boolean drawIt) -> None"},
517 {"LScroll", (PyCFunction
)ListObj_LScroll
, 1,
518 "(short dCols, short dRows) -> None"},
519 {"LAutoScroll", (PyCFunction
)ListObj_LAutoScroll
, 1,
521 {"LUpdate", (PyCFunction
)ListObj_LUpdate
, 1,
523 {"LActivate", (PyCFunction
)ListObj_LActivate
, 1,
524 "(Boolean act) -> None"},
525 {"LCellSize", (PyCFunction
)ListObj_LCellSize
, 1,
526 "(Point cSize) -> None"},
527 {"LClick", (PyCFunction
)ListObj_LClick
, 1,
528 "(Point pt, short modifiers) -> (Boolean _rv)"},
529 {"LAddToCell", (PyCFunction
)ListObj_LAddToCell
, 1,
530 "(Buffer dataPtr, Point theCell) -> None"},
531 {"LClrCell", (PyCFunction
)ListObj_LClrCell
, 1,
532 "(Point theCell) -> None"},
533 {"LGetCell", (PyCFunction
)ListObj_LGetCell
, 1,
534 "(Buffer dataPtr, Point theCell) -> (Buffer dataPtr)"},
535 {"LRect", (PyCFunction
)ListObj_LRect
, 1,
536 "(Point theCell) -> (Rect cellRect)"},
537 {"LSetCell", (PyCFunction
)ListObj_LSetCell
, 1,
538 "(Buffer dataPtr, Point theCell) -> None"},
539 {"LSetSelect", (PyCFunction
)ListObj_LSetSelect
, 1,
540 "(Boolean setIt, Point theCell) -> None"},
541 {"LDraw", (PyCFunction
)ListObj_LDraw
, 1,
542 "(Point theCell) -> None"},
546 PyMethodChain ListObj_chain
= { ListObj_methods
, NULL
};
548 static PyObject
*ListObj_getattr(self
, name
)
552 return Py_FindMethodInChain(&ListObj_chain
, (PyObject
*)self
, name
);
555 #define ListObj_setattr NULL
557 PyTypeObject List_Type
= {
558 PyObject_HEAD_INIT(&PyType_Type
)
561 sizeof(ListObject
), /*tp_basicsize*/
564 (destructor
) ListObj_dealloc
, /*tp_dealloc*/
566 (getattrfunc
) ListObj_getattr
, /*tp_getattr*/
567 (setattrfunc
) ListObj_setattr
, /*tp_setattr*/
570 /* ---------------------- End object type List ---------------------- */
573 static PyObject
*List_LNew(_self
, _args
)
577 PyObject
*_res
= NULL
;
588 if (!PyArg_ParseTuple(_args
, "O&O&O&hO&bbbb",
589 PyMac_GetRect
, &rView
,
590 PyMac_GetRect
, &dataBounds
,
591 PyMac_GetPoint
, &cSize
,
593 WinObj_Convert
, &theWindow
,
608 _res
= Py_BuildValue("O&",
613 static PyMethodDef List_methods
[] = {
614 {"LNew", (PyCFunction
)List_LNew
, 1,
615 "(Rect rView, Rect dataBounds, Point cSize, short theProc, WindowPtr theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert) -> (ListRef _rv)"},
630 m
= Py_InitModule("List", List_methods
);
631 d
= PyModule_GetDict(m
);
632 List_Error
= PyMac_GetOSErrException();
633 if (List_Error
== NULL
||
634 PyDict_SetItemString(d
, "Error", List_Error
) != 0)
635 Py_FatalError("can't initialize List.Error");
638 /* ======================== End module List ========================= */