blob: f459c11f63eeb2c71d3a911db61b1d7a4771ea5e [file] [log] [blame]
Jack Jansen90ecdf41996-04-16 14:29:15 +00001
2/* ========================== Module waste ========================== */
3
4#include "Python.h"
5
6
7
Jack Jansen620a7662001-12-18 15:39:38 +00008#ifdef _WIN32
9#include "pywintoolbox.h"
10#else
Jack Jansen90ecdf41996-04-16 14:29:15 +000011#include "macglue.h"
Jack Jansen9d8b96c2000-07-14 22:16:45 +000012#include "pymactoolbox.h"
Jack Jansen620a7662001-12-18 15:39:38 +000013#endif
Jack Jansen044d95e2001-09-05 15:44:37 +000014
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)
21
Jack Jansen90ecdf41996-04-16 14:29:15 +000022
23#include <WASTE.h>
Jack Jansen8505ef81997-08-27 14:09:25 +000024#include <WEObjectHandlers.h>
Jack Jansena755e681997-09-20 17:40:22 +000025#include <WETabs.h>
Jack Jansen90ecdf41996-04-16 14:29:15 +000026
27/* Exported by Qdmodule.c: */
28extern PyObject *QdRGB_New(RGBColor *);
29extern int QdRGB_Convert(PyObject *, RGBColor *);
30
Jack Jansen8505ef81997-08-27 14:09:25 +000031/* Exported by AEModule.c: */
32extern PyObject *AEDesc_New(AppleEvent *);
33extern int AEDesc_Convert(PyObject *, AppleEvent *);
34
Jack Jansen90ecdf41996-04-16 14:29:15 +000035/* Forward declaration */
36staticforward PyObject *WEOObj_New(WEObjectReference);
Jack Jansen756522f1996-05-07 15:24:01 +000037staticforward PyObject *ExistingwasteObj_New(WEReference);
Jack Jansen90ecdf41996-04-16 14:29:15 +000038
39/*
40** Parse/generate TextStyle records
41*/
42static
43PyObject *TextStyle_New(itself)
44 TextStylePtr itself;
45{
46
47 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
48 &itself->tsColor);
49}
50
51static
52TextStyle_Convert(v, p_itself)
53 PyObject *v;
54 TextStylePtr p_itself;
55{
56 long font, face, size;
57
58 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
59 return 0;
60 p_itself->tsFont = (short)font;
61 p_itself->tsFace = (Style)face;
62 p_itself->tsSize = (short)size;
63 return 1;
64}
65
66/*
67** Parse/generate RunInfo records
68*/
69static
70PyObject *RunInfo_New(itself)
71 WERunInfo *itself;
72{
73
74 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
75 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
76}
77
78/* Conversion of long points and rects */
79int
80LongRect_Convert(PyObject *v, LongRect *r)
81{
82 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
83}
84
85PyObject *
86LongRect_New(LongRect *r)
87{
88 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
89}
90
91
92LongPt_Convert(PyObject *v, LongPt *p)
93{
94 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
95}
96
97PyObject *
98LongPt_New(LongPt *p)
99{
100 return Py_BuildValue("(ll)", p->h, p->v);
101}
102
Jack Jansen756522f1996-05-07 15:24:01 +0000103/* Stuff for the callbacks: */
104static PyObject *callbackdict;
Jack Jansen25241d91996-05-20 11:30:45 +0000105WENewObjectUPP upp_new_handler;
106WEDisposeObjectUPP upp_dispose_handler;
107WEDrawObjectUPP upp_draw_handler;
108WEClickObjectUPP upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +0000109
110static OSErr
111any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
112{
113 FlavorType tp;
114 PyObject *key, *func;
115
116 if ( args == NULL ) return errAECorruptData;
117
118 tp = WEGetObjectType(who);
119
120 if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
121 return errAECorruptData;
122 if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
123 Py_DECREF(key);
124 return errAEHandlerNotFound;
125 }
126 Py_INCREF(func);
127 *rv = PyEval_CallObject(func, args);
128 Py_DECREF(func);
129 Py_DECREF(key);
130 if ( *rv == NULL ) {
Jack Jansendeff89c1998-10-12 20:53:15 +0000131 PySys_WriteStderr("--Exception in callback: ");
Jack Jansen756522f1996-05-07 15:24:01 +0000132 PyErr_Print();
133 return errAEReplyNotArrived;
134 }
135 return 0;
136}
137
138static pascal OSErr
139my_new_handler(Point *objectSize, WEObjectReference objref)
140{
141 PyObject *args=NULL, *rv=NULL;
142 OSErr err;
143
144 args=Py_BuildValue("(O&)", WEOObj_New, objref);
145 err = any_handler(weNewHandler, objref, args, &rv);
146 if (!err) {
147 if (!PyMac_GetPoint(rv, objectSize) )
148 err = errAECoercionFail;
149 }
150 if ( args ) Py_DECREF(args);
151 if ( rv ) Py_DECREF(rv);
152 return err;
153}
154
155static pascal OSErr
156my_dispose_handler(WEObjectReference objref)
157{
158 PyObject *args=NULL, *rv=NULL;
159 OSErr err;
160
161 args=Py_BuildValue("(O&)", WEOObj_New, objref);
162 err = any_handler(weDisposeHandler, objref, args, &rv);
163 if ( args ) Py_DECREF(args);
164 if ( rv ) Py_DECREF(rv);
165 return err;
166}
167
168static pascal OSErr
Jack Jansen6b9289f2001-06-20 21:21:07 +0000169my_draw_handler(const Rect *destRect, WEObjectReference objref)
Jack Jansen756522f1996-05-07 15:24:01 +0000170{
171 PyObject *args=NULL, *rv=NULL;
172 OSErr err;
173
174 args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
175 err = any_handler(weDrawHandler, objref, args, &rv);
176 if ( args ) Py_DECREF(args);
177 if ( rv ) Py_DECREF(rv);
178 return err;
179}
180
181static pascal Boolean
182my_click_handler(Point hitPt, EventModifiers modifiers,
183 unsigned long clickTime, WEObjectReference objref)
184{
185 PyObject *args=NULL, *rv=NULL;
186 int retvalue;
187 OSErr err;
188
189 args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
190 (long)modifiers, (long)clickTime, WEOObj_New, objref);
191 err = any_handler(weClickHandler, objref, args, &rv);
192 if (!err)
193 retvalue = PyInt_AsLong(rv);
194 else
195 retvalue = 0;
196 if ( args ) Py_DECREF(args);
197 if ( rv ) Py_DECREF(rv);
198 return retvalue;
199}
200
201
202
Jack Jansen90ecdf41996-04-16 14:29:15 +0000203static PyObject *waste_Error;
204
205/* ------------------------ Object type WEO ------------------------- */
206
207PyTypeObject WEO_Type;
208
209#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
210
211typedef struct WEOObject {
212 PyObject_HEAD
213 WEObjectReference ob_itself;
214} WEOObject;
215
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000216PyObject *WEOObj_New(WEObjectReference itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000217{
218 WEOObject *it;
219 if (itself == NULL) {
220 Py_INCREF(Py_None);
221 return Py_None;
222 }
223 it = PyObject_NEW(WEOObject, &WEO_Type);
224 if (it == NULL) return NULL;
225 it->ob_itself = itself;
226 return (PyObject *)it;
227}
Jack Jansen044d95e2001-09-05 15:44:37 +0000228int WEOObj_Convert(PyObject *v, WEObjectReference *p_itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000229{
230 if (!WEOObj_Check(v))
231 {
232 PyErr_SetString(PyExc_TypeError, "WEO required");
233 return 0;
234 }
235 *p_itself = ((WEOObject *)v)->ob_itself;
236 return 1;
237}
238
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000239static void WEOObj_dealloc(WEOObject *self)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000240{
241 /* Cleanup of self->ob_itself goes here */
242 PyMem_DEL(self);
243}
244
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000245static PyObject *WEOObj_WEGetObjectType(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000246{
247 PyObject *_res = NULL;
248 FlavorType _rv;
249 if (!PyArg_ParseTuple(_args, ""))
250 return NULL;
251 _rv = WEGetObjectType(_self->ob_itself);
252 _res = Py_BuildValue("O&",
253 PyMac_BuildOSType, _rv);
254 return _res;
255}
256
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000257static PyObject *WEOObj_WEGetObjectDataHandle(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000258{
259 PyObject *_res = NULL;
260 Handle _rv;
261 if (!PyArg_ParseTuple(_args, ""))
262 return NULL;
263 _rv = WEGetObjectDataHandle(_self->ob_itself);
264 _res = Py_BuildValue("O&",
265 ResObj_New, _rv);
266 return _res;
267}
268
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000269static PyObject *WEOObj_WEGetObjectSize(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000270{
271 PyObject *_res = NULL;
272 Point _rv;
273 if (!PyArg_ParseTuple(_args, ""))
274 return NULL;
275 _rv = WEGetObjectSize(_self->ob_itself);
276 _res = Py_BuildValue("O&",
277 PyMac_BuildPoint, _rv);
278 return _res;
279}
280
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000281static PyObject *WEOObj_WEGetObjectOwner(WEOObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +0000282{
283 PyObject *_res = NULL;
284 WEReference _rv;
285 if (!PyArg_ParseTuple(_args, ""))
286 return NULL;
287 _rv = WEGetObjectOwner(_self->ob_itself);
288 _res = Py_BuildValue("O&",
289 ExistingwasteObj_New, _rv);
290 return _res;
291}
292
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000293static PyObject *WEOObj_WEGetObjectRefCon(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000294{
295 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000296 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000297 if (!PyArg_ParseTuple(_args, ""))
298 return NULL;
299 _rv = WEGetObjectRefCon(_self->ob_itself);
300 _res = Py_BuildValue("l",
301 _rv);
302 return _res;
303}
304
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000305static PyObject *WEOObj_WESetObjectRefCon(WEOObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000306{
307 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000308 SInt32 refCon;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000309 if (!PyArg_ParseTuple(_args, "l",
310 &refCon))
311 return NULL;
312 WESetObjectRefCon(_self->ob_itself,
313 refCon);
314 Py_INCREF(Py_None);
315 _res = Py_None;
316 return _res;
317}
318
319static PyMethodDef WEOObj_methods[] = {
320 {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1,
321 "() -> (FlavorType _rv)"},
322 {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1,
323 "() -> (Handle _rv)"},
324 {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1,
325 "() -> (Point _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +0000326 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
327 "() -> (WEReference _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000328 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000329 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000330 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000331 "(SInt32 refCon) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000332 {NULL, NULL, 0}
333};
334
335PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
336
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000337static PyObject *WEOObj_getattr(WEOObject *self, char *name)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000338{
339 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
340}
341
342#define WEOObj_setattr NULL
343
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000344#define WEOObj_compare NULL
345
346#define WEOObj_repr NULL
347
348#define WEOObj_hash NULL
349
Jack Jansen90ecdf41996-04-16 14:29:15 +0000350PyTypeObject WEO_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +0000351 PyObject_HEAD_INIT(NULL)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000352 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +0000353 "waste.WEO", /*tp_name*/
Jack Jansen90ecdf41996-04-16 14:29:15 +0000354 sizeof(WEOObject), /*tp_basicsize*/
355 0, /*tp_itemsize*/
356 /* methods */
357 (destructor) WEOObj_dealloc, /*tp_dealloc*/
358 0, /*tp_print*/
359 (getattrfunc) WEOObj_getattr, /*tp_getattr*/
360 (setattrfunc) WEOObj_setattr, /*tp_setattr*/
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000361 (cmpfunc) WEOObj_compare, /*tp_compare*/
362 (reprfunc) WEOObj_repr, /*tp_repr*/
363 (PyNumberMethods *)0, /* tp_as_number */
364 (PySequenceMethods *)0, /* tp_as_sequence */
365 (PyMappingMethods *)0, /* tp_as_mapping */
366 (hashfunc) WEOObj_hash, /*tp_hash*/
Jack Jansen90ecdf41996-04-16 14:29:15 +0000367};
368
369/* ---------------------- End object type WEO ----------------------- */
370
371
372/* ----------------------- Object type waste ------------------------ */
373
374PyTypeObject waste_Type;
375
376#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
377
378typedef struct wasteObject {
379 PyObject_HEAD
380 WEReference ob_itself;
381} wasteObject;
382
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000383PyObject *wasteObj_New(WEReference itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000384{
385 wasteObject *it;
386 if (itself == NULL) {
387 PyErr_SetString(waste_Error,"Cannot create null WE");
388 return NULL;
389 }
390 it = PyObject_NEW(wasteObject, &waste_Type);
391 if (it == NULL) return NULL;
392 it->ob_itself = itself;
Jack Jansen756522f1996-05-07 15:24:01 +0000393 WESetInfo(weRefCon, (void *)&it, itself);
Jack Jansen90ecdf41996-04-16 14:29:15 +0000394 return (PyObject *)it;
395}
Jack Jansen044d95e2001-09-05 15:44:37 +0000396int wasteObj_Convert(PyObject *v, WEReference *p_itself)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000397{
398 if (!wasteObj_Check(v))
399 {
400 PyErr_SetString(PyExc_TypeError, "waste required");
401 return 0;
402 }
403 *p_itself = ((wasteObject *)v)->ob_itself;
404 return 1;
405}
406
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000407static void wasteObj_dealloc(wasteObject *self)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000408{
409 WEDispose(self->ob_itself);
410 PyMem_DEL(self);
411}
412
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000413static PyObject *wasteObj_WEGetText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000414{
415 PyObject *_res = NULL;
416 Handle _rv;
417 if (!PyArg_ParseTuple(_args, ""))
418 return NULL;
419 _rv = WEGetText(_self->ob_itself);
420 _res = Py_BuildValue("O&",
421 ResObj_New, _rv);
422 return _res;
423}
424
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000425static PyObject *wasteObj_WEGetChar(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000426{
427 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000428 SInt16 _rv;
429 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000430 if (!PyArg_ParseTuple(_args, "l",
431 &offset))
432 return NULL;
433 _rv = WEGetChar(offset,
434 _self->ob_itself);
435 _res = Py_BuildValue("h",
436 _rv);
437 return _res;
438}
439
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000440static PyObject *wasteObj_WEGetTextLength(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000441{
442 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000443 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000444 if (!PyArg_ParseTuple(_args, ""))
445 return NULL;
446 _rv = WEGetTextLength(_self->ob_itself);
447 _res = Py_BuildValue("l",
448 _rv);
449 return _res;
450}
451
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000452static PyObject *wasteObj_WEGetHeight(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000453{
454 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000455 SInt32 _rv;
456 SInt32 startLine;
457 SInt32 endLine;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000458 if (!PyArg_ParseTuple(_args, "ll",
459 &startLine,
460 &endLine))
461 return NULL;
462 _rv = WEGetHeight(startLine,
463 endLine,
464 _self->ob_itself);
465 _res = Py_BuildValue("l",
466 _rv);
467 return _res;
468}
469
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000470static PyObject *wasteObj_WEGetSelection(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000471{
472 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000473 SInt32 selStart;
474 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000475 if (!PyArg_ParseTuple(_args, ""))
476 return NULL;
477 WEGetSelection(&selStart,
478 &selEnd,
479 _self->ob_itself);
480 _res = Py_BuildValue("ll",
481 selStart,
482 selEnd);
483 return _res;
484}
485
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000486static PyObject *wasteObj_WEGetDestRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000487{
488 PyObject *_res = NULL;
489 LongRect destRect;
490 if (!PyArg_ParseTuple(_args, ""))
491 return NULL;
492 WEGetDestRect(&destRect,
493 _self->ob_itself);
494 _res = Py_BuildValue("O&",
495 LongRect_New, &destRect);
496 return _res;
497}
498
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000499static PyObject *wasteObj_WEGetViewRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000500{
501 PyObject *_res = NULL;
502 LongRect viewRect;
503 if (!PyArg_ParseTuple(_args, ""))
504 return NULL;
505 WEGetViewRect(&viewRect,
506 _self->ob_itself);
507 _res = Py_BuildValue("O&",
508 LongRect_New, &viewRect);
509 return _res;
510}
511
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000512static PyObject *wasteObj_WEIsActive(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000513{
514 PyObject *_res = NULL;
515 Boolean _rv;
516 if (!PyArg_ParseTuple(_args, ""))
517 return NULL;
518 _rv = WEIsActive(_self->ob_itself);
519 _res = Py_BuildValue("b",
520 _rv);
521 return _res;
522}
523
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000524static PyObject *wasteObj_WEOffsetToLine(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000525{
526 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000527 SInt32 _rv;
528 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000529 if (!PyArg_ParseTuple(_args, "l",
530 &offset))
531 return NULL;
532 _rv = WEOffsetToLine(offset,
533 _self->ob_itself);
534 _res = Py_BuildValue("l",
535 _rv);
536 return _res;
537}
538
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000539static PyObject *wasteObj_WEGetLineRange(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000540{
541 PyObject *_res = NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000542 SInt32 lineIndex;
Jack Jansen2268af51996-08-06 16:04:22 +0000543 SInt32 lineStart;
544 SInt32 lineEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000545 if (!PyArg_ParseTuple(_args, "l",
Jack Jansen2369a981998-02-20 15:57:30 +0000546 &lineIndex))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000547 return NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000548 WEGetLineRange(lineIndex,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000549 &lineStart,
550 &lineEnd,
551 _self->ob_itself);
552 _res = Py_BuildValue("ll",
553 lineStart,
554 lineEnd);
555 return _res;
556}
557
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000558static PyObject *wasteObj_WECountLines(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000559{
560 PyObject *_res = NULL;
561 SInt32 _rv;
562 if (!PyArg_ParseTuple(_args, ""))
563 return NULL;
564 _rv = WECountLines(_self->ob_itself);
565 _res = Py_BuildValue("l",
566 _rv);
567 return _res;
568}
569
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000570static PyObject *wasteObj_WEOffsetToRun(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000571{
572 PyObject *_res = NULL;
573 SInt32 _rv;
574 SInt32 offset;
575 if (!PyArg_ParseTuple(_args, "l",
576 &offset))
577 return NULL;
578 _rv = WEOffsetToRun(offset,
579 _self->ob_itself);
580 _res = Py_BuildValue("l",
581 _rv);
582 return _res;
583}
584
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000585static PyObject *wasteObj_WEGetRunRange(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000586{
587 PyObject *_res = NULL;
588 SInt32 runIndex;
589 SInt32 runStart;
590 SInt32 runEnd;
591 if (!PyArg_ParseTuple(_args, "l",
592 &runIndex))
593 return NULL;
594 WEGetRunRange(runIndex,
595 &runStart,
596 &runEnd,
597 _self->ob_itself);
598 _res = Py_BuildValue("ll",
599 runStart,
600 runEnd);
601 return _res;
602}
603
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000604static PyObject *wasteObj_WECountRuns(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000605{
606 PyObject *_res = NULL;
607 SInt32 _rv;
608 if (!PyArg_ParseTuple(_args, ""))
609 return NULL;
610 _rv = WECountRuns(_self->ob_itself);
611 _res = Py_BuildValue("l",
612 _rv);
613 return _res;
614}
615
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000616static PyObject *wasteObj_WEGetClickCount(wasteObject *_self, PyObject *_args)
Jack Jansen2268af51996-08-06 16:04:22 +0000617{
618 PyObject *_res = NULL;
619 UInt16 _rv;
620 if (!PyArg_ParseTuple(_args, ""))
621 return NULL;
622 _rv = WEGetClickCount(_self->ob_itself);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000623 _res = Py_BuildValue("H",
Jack Jansen2268af51996-08-06 16:04:22 +0000624 _rv);
625 return _res;
626}
627
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000628static PyObject *wasteObj_WESetSelection(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000629{
630 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000631 SInt32 selStart;
632 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000633 if (!PyArg_ParseTuple(_args, "ll",
634 &selStart,
635 &selEnd))
636 return NULL;
637 WESetSelection(selStart,
638 selEnd,
639 _self->ob_itself);
640 Py_INCREF(Py_None);
641 _res = Py_None;
642 return _res;
643}
644
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000645static PyObject *wasteObj_WESetDestRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000646{
647 PyObject *_res = NULL;
648 LongRect destRect;
649 if (!PyArg_ParseTuple(_args, "O&",
650 LongRect_Convert, &destRect))
651 return NULL;
652 WESetDestRect(&destRect,
653 _self->ob_itself);
654 Py_INCREF(Py_None);
655 _res = Py_None;
656 return _res;
657}
658
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000659static PyObject *wasteObj_WESetViewRect(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000660{
661 PyObject *_res = NULL;
662 LongRect viewRect;
663 if (!PyArg_ParseTuple(_args, "O&",
664 LongRect_Convert, &viewRect))
665 return NULL;
666 WESetViewRect(&viewRect,
667 _self->ob_itself);
668 Py_INCREF(Py_None);
669 _res = Py_None;
670 return _res;
671}
672
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000673static PyObject *wasteObj_WEContinuousStyle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000674{
675 PyObject *_res = NULL;
676 Boolean _rv;
677 WEStyleMode mode;
678 TextStyle ts;
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000679 if (!PyArg_ParseTuple(_args, "H",
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000680 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000681 return NULL;
682 _rv = WEContinuousStyle(&mode,
683 &ts,
684 _self->ob_itself);
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000685 _res = Py_BuildValue("bHO&",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000686 _rv,
687 mode,
688 TextStyle_New, &ts);
689 return _res;
690}
691
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000692static PyObject *wasteObj_WEGetRunInfo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000693{
694 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000695 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000696 WERunInfo runInfo;
697 if (!PyArg_ParseTuple(_args, "l",
698 &offset))
699 return NULL;
700 WEGetRunInfo(offset,
701 &runInfo,
702 _self->ob_itself);
703 _res = Py_BuildValue("O&",
704 RunInfo_New, &runInfo);
705 return _res;
706}
707
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000708static PyObject *wasteObj_WEGetRunDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000709{
710 PyObject *_res = NULL;
711 Boolean _rv;
712 SInt32 offset;
713 if (!PyArg_ParseTuple(_args, "l",
714 &offset))
715 return NULL;
716 _rv = WEGetRunDirection(offset,
717 _self->ob_itself);
718 _res = Py_BuildValue("b",
719 _rv);
720 return _res;
721}
722
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000723static PyObject *wasteObj_WEGetOffset(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000724{
725 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000726 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000727 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000728 WEEdge edge;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000729 if (!PyArg_ParseTuple(_args, "O&",
730 LongPt_Convert, &thePoint))
731 return NULL;
732 _rv = WEGetOffset(&thePoint,
733 &edge,
734 _self->ob_itself);
Jack Jansen97ed9072000-09-08 22:06:16 +0000735 _res = Py_BuildValue("lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000736 _rv,
737 edge);
738 return _res;
739}
740
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000741static PyObject *wasteObj_WEGetPoint(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000742{
743 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000744 SInt32 offset;
745 SInt16 direction;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000746 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000747 SInt16 lineHeight;
748 if (!PyArg_ParseTuple(_args, "lh",
749 &offset,
750 &direction))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000751 return NULL;
752 WEGetPoint(offset,
Jack Jansen2268af51996-08-06 16:04:22 +0000753 direction,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000754 &thePoint,
755 &lineHeight,
756 _self->ob_itself);
757 _res = Py_BuildValue("O&h",
758 LongPt_New, &thePoint,
759 lineHeight);
760 return _res;
761}
762
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000763static PyObject *wasteObj_WEFindWord(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000764{
765 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000766 SInt32 offset;
767 WEEdge edge;
768 SInt32 wordStart;
769 SInt32 wordEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000770 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000771 &offset,
772 &edge))
773 return NULL;
774 WEFindWord(offset,
775 edge,
776 &wordStart,
777 &wordEnd,
778 _self->ob_itself);
779 _res = Py_BuildValue("ll",
780 wordStart,
781 wordEnd);
782 return _res;
783}
784
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000785static PyObject *wasteObj_WEFindLine(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000786{
787 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000788 SInt32 offset;
789 WEEdge edge;
790 SInt32 lineStart;
791 SInt32 lineEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000792 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000793 &offset,
794 &edge))
795 return NULL;
796 WEFindLine(offset,
797 edge,
798 &lineStart,
799 &lineEnd,
800 _self->ob_itself);
801 _res = Py_BuildValue("ll",
802 lineStart,
803 lineEnd);
804 return _res;
805}
806
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000807static PyObject *wasteObj_WEFindParagraph(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000808{
809 PyObject *_res = NULL;
810 SInt32 offset;
811 WEEdge edge;
812 SInt32 paragraphStart;
813 SInt32 paragraphEnd;
Jack Jansen97ed9072000-09-08 22:06:16 +0000814 if (!PyArg_ParseTuple(_args, "lB",
Jack Jansen2369a981998-02-20 15:57:30 +0000815 &offset,
816 &edge))
817 return NULL;
818 WEFindParagraph(offset,
819 edge,
820 &paragraphStart,
821 &paragraphEnd,
822 _self->ob_itself);
823 _res = Py_BuildValue("ll",
824 paragraphStart,
825 paragraphEnd);
826 return _res;
827}
828
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000829static PyObject *wasteObj_WECopyRange(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000830{
831 PyObject *_res = NULL;
832 OSErr _err;
Jack Jansen2268af51996-08-06 16:04:22 +0000833 SInt32 rangeStart;
834 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000835 Handle hText;
836 StScrpHandle hStyles;
837 WESoupHandle hSoup;
838 if (!PyArg_ParseTuple(_args, "llO&O&O&",
839 &rangeStart,
840 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000841 OptResObj_Convert, &hText,
842 OptResObj_Convert, &hStyles,
843 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000844 return NULL;
845 _err = WECopyRange(rangeStart,
846 rangeEnd,
847 hText,
848 hStyles,
849 hSoup,
850 _self->ob_itself);
851 if (_err != noErr) return PyMac_Error(_err);
852 Py_INCREF(Py_None);
853 _res = Py_None;
854 return _res;
855}
856
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000857static PyObject *wasteObj_WEGetAlignment(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000858{
859 PyObject *_res = NULL;
860 WEAlignment _rv;
861 if (!PyArg_ParseTuple(_args, ""))
862 return NULL;
863 _rv = WEGetAlignment(_self->ob_itself);
Jack Jansen97ed9072000-09-08 22:06:16 +0000864 _res = Py_BuildValue("B",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000865 _rv);
866 return _res;
867}
868
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000869static PyObject *wasteObj_WESetAlignment(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000870{
871 PyObject *_res = NULL;
872 WEAlignment alignment;
Jack Jansen97ed9072000-09-08 22:06:16 +0000873 if (!PyArg_ParseTuple(_args, "B",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000874 &alignment))
875 return NULL;
876 WESetAlignment(alignment,
877 _self->ob_itself);
878 Py_INCREF(Py_None);
879 _res = Py_None;
880 return _res;
881}
882
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000883static PyObject *wasteObj_WEGetDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000884{
885 PyObject *_res = NULL;
886 WEDirection _rv;
887 if (!PyArg_ParseTuple(_args, ""))
888 return NULL;
889 _rv = WEGetDirection(_self->ob_itself);
890 _res = Py_BuildValue("h",
891 _rv);
892 return _res;
893}
894
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000895static PyObject *wasteObj_WESetDirection(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +0000896{
897 PyObject *_res = NULL;
898 WEDirection direction;
899 if (!PyArg_ParseTuple(_args, "h",
900 &direction))
901 return NULL;
902 WESetDirection(direction,
903 _self->ob_itself);
904 Py_INCREF(Py_None);
905 _res = Py_None;
906 return _res;
907}
908
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000909static PyObject *wasteObj_WECalText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000910{
911 PyObject *_res = NULL;
912 OSErr _err;
913 if (!PyArg_ParseTuple(_args, ""))
914 return NULL;
915 _err = WECalText(_self->ob_itself);
916 if (_err != noErr) return PyMac_Error(_err);
917 Py_INCREF(Py_None);
918 _res = Py_None;
919 return _res;
920}
921
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000922static PyObject *wasteObj_WEUpdate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000923{
924 PyObject *_res = NULL;
925 RgnHandle updateRgn;
926 if (!PyArg_ParseTuple(_args, "O&",
927 ResObj_Convert, &updateRgn))
928 return NULL;
929 WEUpdate(updateRgn,
930 _self->ob_itself);
931 Py_INCREF(Py_None);
932 _res = Py_None;
933 return _res;
934}
935
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000936static PyObject *wasteObj_WEScroll(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000937{
938 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000939 SInt32 hOffset;
940 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000941 if (!PyArg_ParseTuple(_args, "ll",
942 &hOffset,
943 &vOffset))
944 return NULL;
945 WEScroll(hOffset,
946 vOffset,
947 _self->ob_itself);
948 Py_INCREF(Py_None);
949 _res = Py_None;
950 return _res;
951}
952
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000953static PyObject *wasteObj_WESelView(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000954{
955 PyObject *_res = NULL;
956 if (!PyArg_ParseTuple(_args, ""))
957 return NULL;
958 WESelView(_self->ob_itself);
959 Py_INCREF(Py_None);
960 _res = Py_None;
961 return _res;
962}
963
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000964static PyObject *wasteObj_WEActivate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000965{
966 PyObject *_res = NULL;
967 if (!PyArg_ParseTuple(_args, ""))
968 return NULL;
969 WEActivate(_self->ob_itself);
970 Py_INCREF(Py_None);
971 _res = Py_None;
972 return _res;
973}
974
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000975static PyObject *wasteObj_WEDeactivate(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000976{
977 PyObject *_res = NULL;
978 if (!PyArg_ParseTuple(_args, ""))
979 return NULL;
980 WEDeactivate(_self->ob_itself);
981 Py_INCREF(Py_None);
982 _res = Py_None;
983 return _res;
984}
985
Jack Jansenfa77e1a2001-05-22 21:56:42 +0000986static PyObject *wasteObj_WEKey(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +0000987{
988 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000989 SInt16 key;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000990 EventModifiers modifiers;
Jack Jansen9d8b96c2000-07-14 22:16:45 +0000991 if (!PyArg_ParseTuple(_args, "hH",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000992 &key,
993 &modifiers))
994 return NULL;
995 WEKey(key,
996 modifiers,
997 _self->ob_itself);
998 Py_INCREF(Py_None);
999 _res = Py_None;
1000 return _res;
1001}
1002
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001003static PyObject *wasteObj_WEClick(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001004{
1005 PyObject *_res = NULL;
1006 Point hitPt;
1007 EventModifiers modifiers;
Jack Jansen2268af51996-08-06 16:04:22 +00001008 UInt32 clickTime;
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001009 if (!PyArg_ParseTuple(_args, "O&Hl",
Jack Jansen90ecdf41996-04-16 14:29:15 +00001010 PyMac_GetPoint, &hitPt,
1011 &modifiers,
1012 &clickTime))
1013 return NULL;
1014 WEClick(hitPt,
1015 modifiers,
1016 clickTime,
1017 _self->ob_itself);
1018 Py_INCREF(Py_None);
1019 _res = Py_None;
1020 return _res;
1021}
1022
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001023static PyObject *wasteObj_WEAdjustCursor(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001024{
1025 PyObject *_res = NULL;
1026 Boolean _rv;
1027 Point mouseLoc;
1028 RgnHandle mouseRgn;
1029 if (!PyArg_ParseTuple(_args, "O&O&",
1030 PyMac_GetPoint, &mouseLoc,
1031 ResObj_Convert, &mouseRgn))
1032 return NULL;
1033 _rv = WEAdjustCursor(mouseLoc,
1034 mouseRgn,
1035 _self->ob_itself);
1036 _res = Py_BuildValue("b",
1037 _rv);
1038 return _res;
1039}
1040
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001041static PyObject *wasteObj_WEIdle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001042{
1043 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001044 UInt32 maxSleep;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001045 if (!PyArg_ParseTuple(_args, ""))
1046 return NULL;
1047 WEIdle(&maxSleep,
1048 _self->ob_itself);
1049 _res = Py_BuildValue("l",
1050 maxSleep);
1051 return _res;
1052}
1053
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001054static PyObject *wasteObj_WEInsert(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001055{
1056 PyObject *_res = NULL;
1057 OSErr _err;
1058 char *pText__in__;
1059 long pText__len__;
1060 int pText__in_len__;
1061 StScrpHandle hStyles;
1062 WESoupHandle hSoup;
1063 if (!PyArg_ParseTuple(_args, "s#O&O&",
1064 &pText__in__, &pText__in_len__,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001065 OptResObj_Convert, &hStyles,
1066 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +00001067 return NULL;
1068 pText__len__ = pText__in_len__;
1069 _err = WEInsert(pText__in__, pText__len__,
1070 hStyles,
1071 hSoup,
1072 _self->ob_itself);
1073 if (_err != noErr) return PyMac_Error(_err);
1074 Py_INCREF(Py_None);
1075 _res = Py_None;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001076 return _res;
1077}
1078
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001079static PyObject *wasteObj_WEDelete(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001080{
1081 PyObject *_res = NULL;
1082 OSErr _err;
1083 if (!PyArg_ParseTuple(_args, ""))
1084 return NULL;
1085 _err = WEDelete(_self->ob_itself);
1086 if (_err != noErr) return PyMac_Error(_err);
1087 Py_INCREF(Py_None);
1088 _res = Py_None;
1089 return _res;
1090}
1091
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001092static PyObject *wasteObj_WESetStyle(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001093{
1094 PyObject *_res = NULL;
1095 OSErr _err;
1096 WEStyleMode mode;
1097 TextStyle ts;
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001098 if (!PyArg_ParseTuple(_args, "HO&",
Jack Jansen90ecdf41996-04-16 14:29:15 +00001099 &mode,
1100 TextStyle_Convert, &ts))
1101 return NULL;
1102 _err = WESetStyle(mode,
1103 &ts,
1104 _self->ob_itself);
1105 if (_err != noErr) return PyMac_Error(_err);
1106 Py_INCREF(Py_None);
1107 _res = Py_None;
1108 return _res;
1109}
1110
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001111static PyObject *wasteObj_WEUseStyleScrap(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001112{
1113 PyObject *_res = NULL;
1114 OSErr _err;
1115 StScrpHandle hStyles;
1116 if (!PyArg_ParseTuple(_args, "O&",
1117 ResObj_Convert, &hStyles))
1118 return NULL;
1119 _err = WEUseStyleScrap(hStyles,
1120 _self->ob_itself);
1121 if (_err != noErr) return PyMac_Error(_err);
1122 Py_INCREF(Py_None);
1123 _res = Py_None;
1124 return _res;
1125}
1126
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001127static PyObject *wasteObj_WEUseText(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001128{
1129 PyObject *_res = NULL;
1130 OSErr _err;
1131 Handle hText;
1132 if (!PyArg_ParseTuple(_args, "O&",
1133 ResObj_Convert, &hText))
1134 return NULL;
1135 _err = WEUseText(hText,
1136 _self->ob_itself);
1137 if (_err != noErr) return PyMac_Error(_err);
1138 Py_INCREF(Py_None);
1139 _res = Py_None;
1140 return _res;
1141}
1142
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001143static PyObject *wasteObj_WEUndo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001144{
1145 PyObject *_res = NULL;
1146 OSErr _err;
1147 if (!PyArg_ParseTuple(_args, ""))
1148 return NULL;
1149 _err = WEUndo(_self->ob_itself);
1150 if (_err != noErr) return PyMac_Error(_err);
1151 Py_INCREF(Py_None);
1152 _res = Py_None;
1153 return _res;
1154}
1155
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001156static PyObject *wasteObj_WEClearUndo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001157{
1158 PyObject *_res = NULL;
1159 if (!PyArg_ParseTuple(_args, ""))
1160 return NULL;
1161 WEClearUndo(_self->ob_itself);
1162 Py_INCREF(Py_None);
1163 _res = Py_None;
1164 return _res;
1165}
1166
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001167static PyObject *wasteObj_WEGetUndoInfo(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001168{
1169 PyObject *_res = NULL;
1170 WEActionKind _rv;
1171 Boolean redoFlag;
1172 if (!PyArg_ParseTuple(_args, ""))
1173 return NULL;
1174 _rv = WEGetUndoInfo(&redoFlag,
1175 _self->ob_itself);
1176 _res = Py_BuildValue("hb",
1177 _rv,
1178 redoFlag);
1179 return _res;
1180}
1181
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001182static PyObject *wasteObj_WEIsTyping(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001183{
1184 PyObject *_res = NULL;
1185 Boolean _rv;
1186 if (!PyArg_ParseTuple(_args, ""))
1187 return NULL;
1188 _rv = WEIsTyping(_self->ob_itself);
1189 _res = Py_BuildValue("b",
1190 _rv);
1191 return _res;
1192}
1193
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001194static PyObject *wasteObj_WEBeginAction(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001195{
1196 PyObject *_res = NULL;
1197 OSErr _err;
1198 if (!PyArg_ParseTuple(_args, ""))
1199 return NULL;
1200 _err = WEBeginAction(_self->ob_itself);
1201 if (_err != noErr) return PyMac_Error(_err);
1202 Py_INCREF(Py_None);
1203 _res = Py_None;
1204 return _res;
1205}
1206
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001207static PyObject *wasteObj_WEEndAction(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001208{
1209 PyObject *_res = NULL;
1210 OSErr _err;
1211 WEActionKind actionKind;
1212 if (!PyArg_ParseTuple(_args, "h",
1213 &actionKind))
1214 return NULL;
1215 _err = WEEndAction(actionKind,
1216 _self->ob_itself);
1217 if (_err != noErr) return PyMac_Error(_err);
1218 Py_INCREF(Py_None);
1219 _res = Py_None;
1220 return _res;
1221}
1222
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001223static PyObject *wasteObj_WEGetModCount(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001224{
1225 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001226 UInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001227 if (!PyArg_ParseTuple(_args, ""))
1228 return NULL;
1229 _rv = WEGetModCount(_self->ob_itself);
1230 _res = Py_BuildValue("l",
1231 _rv);
1232 return _res;
1233}
1234
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001235static PyObject *wasteObj_WEResetModCount(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001236{
1237 PyObject *_res = NULL;
1238 if (!PyArg_ParseTuple(_args, ""))
1239 return NULL;
1240 WEResetModCount(_self->ob_itself);
1241 Py_INCREF(Py_None);
1242 _res = Py_None;
1243 return _res;
1244}
1245
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001246static PyObject *wasteObj_WEInsertObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001247{
1248 PyObject *_res = NULL;
1249 OSErr _err;
1250 FlavorType objectType;
1251 Handle objectDataHandle;
1252 Point objectSize;
1253 if (!PyArg_ParseTuple(_args, "O&O&O&",
1254 PyMac_GetOSType, &objectType,
1255 ResObj_Convert, &objectDataHandle,
1256 PyMac_GetPoint, &objectSize))
1257 return NULL;
1258 _err = WEInsertObject(objectType,
1259 objectDataHandle,
1260 objectSize,
1261 _self->ob_itself);
1262 if (_err != noErr) return PyMac_Error(_err);
1263 Py_INCREF(Py_None);
1264 _res = Py_None;
1265 return _res;
1266}
1267
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001268static PyObject *wasteObj_WEGetSelectedObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001269{
1270 PyObject *_res = NULL;
1271 OSErr _err;
1272 WEObjectReference obj;
1273 if (!PyArg_ParseTuple(_args, ""))
1274 return NULL;
1275 _err = WEGetSelectedObject(&obj,
1276 _self->ob_itself);
1277 if (_err != noErr) return PyMac_Error(_err);
1278 _res = Py_BuildValue("O&",
1279 WEOObj_New, obj);
1280 return _res;
1281}
1282
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001283static PyObject *wasteObj_WEFindNextObject(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001284{
1285 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001286 SInt32 _rv;
1287 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001288 WEObjectReference obj;
1289 if (!PyArg_ParseTuple(_args, "l",
1290 &offset))
1291 return NULL;
1292 _rv = WEFindNextObject(offset,
1293 &obj,
1294 _self->ob_itself);
1295 _res = Py_BuildValue("lO&",
1296 _rv,
1297 WEOObj_New, obj);
1298 return _res;
1299}
1300
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001301static PyObject *wasteObj_WEUseSoup(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001302{
1303 PyObject *_res = NULL;
1304 OSErr _err;
1305 WESoupHandle hSoup;
1306 if (!PyArg_ParseTuple(_args, "O&",
1307 ResObj_Convert, &hSoup))
1308 return NULL;
1309 _err = WEUseSoup(hSoup,
1310 _self->ob_itself);
1311 if (_err != noErr) return PyMac_Error(_err);
1312 Py_INCREF(Py_None);
1313 _res = Py_None;
1314 return _res;
1315}
1316
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001317static PyObject *wasteObj_WECut(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001318{
1319 PyObject *_res = NULL;
1320 OSErr _err;
1321 if (!PyArg_ParseTuple(_args, ""))
1322 return NULL;
1323 _err = WECut(_self->ob_itself);
1324 if (_err != noErr) return PyMac_Error(_err);
1325 Py_INCREF(Py_None);
1326 _res = Py_None;
1327 return _res;
1328}
1329
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001330static PyObject *wasteObj_WECopy(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001331{
1332 PyObject *_res = NULL;
1333 OSErr _err;
1334 if (!PyArg_ParseTuple(_args, ""))
1335 return NULL;
1336 _err = WECopy(_self->ob_itself);
1337 if (_err != noErr) return PyMac_Error(_err);
1338 Py_INCREF(Py_None);
1339 _res = Py_None;
1340 return _res;
1341}
1342
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001343static PyObject *wasteObj_WEPaste(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001344{
1345 PyObject *_res = NULL;
1346 OSErr _err;
1347 if (!PyArg_ParseTuple(_args, ""))
1348 return NULL;
1349 _err = WEPaste(_self->ob_itself);
1350 if (_err != noErr) return PyMac_Error(_err);
1351 Py_INCREF(Py_None);
1352 _res = Py_None;
1353 return _res;
1354}
1355
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001356static PyObject *wasteObj_WECanPaste(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001357{
1358 PyObject *_res = NULL;
1359 Boolean _rv;
1360 if (!PyArg_ParseTuple(_args, ""))
1361 return NULL;
1362 _rv = WECanPaste(_self->ob_itself);
1363 _res = Py_BuildValue("b",
1364 _rv);
1365 return _res;
1366}
1367
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001368static PyObject *wasteObj_WEGetHiliteRgn(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001369{
1370 PyObject *_res = NULL;
1371 RgnHandle _rv;
Jack Jansen2268af51996-08-06 16:04:22 +00001372 SInt32 rangeStart;
1373 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001374 if (!PyArg_ParseTuple(_args, "ll",
1375 &rangeStart,
1376 &rangeEnd))
1377 return NULL;
1378 _rv = WEGetHiliteRgn(rangeStart,
1379 rangeEnd,
1380 _self->ob_itself);
1381 _res = Py_BuildValue("O&",
1382 ResObj_New, _rv);
1383 return _res;
1384}
1385
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001386static PyObject *wasteObj_WECharByte(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001387{
1388 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001389 SInt16 _rv;
1390 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001391 if (!PyArg_ParseTuple(_args, "l",
1392 &offset))
1393 return NULL;
1394 _rv = WECharByte(offset,
1395 _self->ob_itself);
1396 _res = Py_BuildValue("h",
1397 _rv);
1398 return _res;
1399}
1400
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001401static PyObject *wasteObj_WECharType(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001402{
1403 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001404 SInt16 _rv;
1405 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001406 if (!PyArg_ParseTuple(_args, "l",
1407 &offset))
1408 return NULL;
1409 _rv = WECharType(offset,
1410 _self->ob_itself);
1411 _res = Py_BuildValue("h",
1412 _rv);
1413 return _res;
1414}
1415
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001416static PyObject *wasteObj_WEStopInlineSession(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001417{
1418 PyObject *_res = NULL;
1419 if (!PyArg_ParseTuple(_args, ""))
1420 return NULL;
1421 WEStopInlineSession(_self->ob_itself);
1422 Py_INCREF(Py_None);
1423 _res = Py_None;
1424 return _res;
1425}
1426
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001427static PyObject *wasteObj_WEFeatureFlag(wasteObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001428{
1429 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001430 SInt16 _rv;
1431 SInt16 feature;
1432 SInt16 action;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001433 if (!PyArg_ParseTuple(_args, "hh",
1434 &feature,
1435 &action))
1436 return NULL;
1437 _rv = WEFeatureFlag(feature,
1438 action,
1439 _self->ob_itself);
1440 _res = Py_BuildValue("h",
1441 _rv);
1442 return _res;
1443}
1444
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001445static PyObject *wasteObj_WEGetUserInfo(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001446{
1447 PyObject *_res = NULL;
1448 OSErr _err;
1449 WESelector tag;
1450 SInt32 userInfo;
1451 if (!PyArg_ParseTuple(_args, "O&",
1452 PyMac_GetOSType, &tag))
1453 return NULL;
1454 _err = WEGetUserInfo(tag,
1455 &userInfo,
1456 _self->ob_itself);
1457 if (_err != noErr) return PyMac_Error(_err);
1458 _res = Py_BuildValue("l",
1459 userInfo);
1460 return _res;
1461}
1462
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001463static PyObject *wasteObj_WESetUserInfo(wasteObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001464{
1465 PyObject *_res = NULL;
1466 OSErr _err;
1467 WESelector tag;
1468 SInt32 userInfo;
1469 if (!PyArg_ParseTuple(_args, "O&l",
1470 PyMac_GetOSType, &tag,
1471 &userInfo))
1472 return NULL;
1473 _err = WESetUserInfo(tag,
1474 userInfo,
1475 _self->ob_itself);
1476 if (_err != noErr) return PyMac_Error(_err);
1477 Py_INCREF(Py_None);
1478 _res = Py_None;
1479 return _res;
1480}
1481
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001482static PyObject *wasteObj_WEInstallTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001483{
1484 PyObject *_res = NULL;
1485 OSErr _err;
1486 if (!PyArg_ParseTuple(_args, ""))
1487 return NULL;
1488 _err = WEInstallTabHooks(_self->ob_itself);
1489 if (_err != noErr) return PyMac_Error(_err);
1490 Py_INCREF(Py_None);
1491 _res = Py_None;
1492 return _res;
1493}
1494
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001495static PyObject *wasteObj_WERemoveTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001496{
1497 PyObject *_res = NULL;
1498 OSErr _err;
1499 if (!PyArg_ParseTuple(_args, ""))
1500 return NULL;
1501 _err = WERemoveTabHooks(_self->ob_itself);
1502 if (_err != noErr) return PyMac_Error(_err);
1503 Py_INCREF(Py_None);
1504 _res = Py_None;
1505 return _res;
1506}
1507
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001508static PyObject *wasteObj_WEIsTabHooks(wasteObject *_self, PyObject *_args)
Jack Jansen176f3a91996-10-23 15:43:46 +00001509{
1510 PyObject *_res = NULL;
1511 Boolean _rv;
1512 if (!PyArg_ParseTuple(_args, ""))
1513 return NULL;
1514 _rv = WEIsTabHooks(_self->ob_itself);
1515 _res = Py_BuildValue("b",
1516 _rv);
1517 return _res;
1518}
1519
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001520static PyObject *wasteObj_WEGetTabSize(wasteObject *_self, PyObject *_args)
Jack Jansena4f03091998-03-02 16:56:18 +00001521{
1522 PyObject *_res = NULL;
1523 SInt16 _rv;
1524 if (!PyArg_ParseTuple(_args, ""))
1525 return NULL;
1526 _rv = WEGetTabSize(_self->ob_itself);
1527 _res = Py_BuildValue("h",
1528 _rv);
1529 return _res;
1530}
1531
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001532static PyObject *wasteObj_WESetTabSize(wasteObject *_self, PyObject *_args)
Jack Jansena4f03091998-03-02 16:56:18 +00001533{
1534 PyObject *_res = NULL;
1535 OSErr _err;
1536 SInt16 tabWidth;
1537 if (!PyArg_ParseTuple(_args, "h",
1538 &tabWidth))
1539 return NULL;
1540 _err = WESetTabSize(tabWidth,
1541 _self->ob_itself);
1542 if (_err != noErr) return PyMac_Error(_err);
1543 Py_INCREF(Py_None);
1544 _res = Py_None;
1545 return _res;
1546}
1547
Jack Jansen90ecdf41996-04-16 14:29:15 +00001548static PyMethodDef wasteObj_methods[] = {
1549 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1550 "() -> (Handle _rv)"},
1551 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001552 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001553 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001554 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001555 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001556 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001557 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001558 "() -> (SInt32 selStart, SInt32 selEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001559 {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1,
1560 "() -> (LongRect destRect)"},
1561 {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1,
1562 "() -> (LongRect viewRect)"},
1563 {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1,
1564 "() -> (Boolean _rv)"},
1565 {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001566 "(SInt32 offset) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001567 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
Jack Jansen2369a981998-02-20 15:57:30 +00001568 "(SInt32 lineIndex) -> (SInt32 lineStart, SInt32 lineEnd)"},
1569 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
1570 "() -> (SInt32 _rv)"},
1571 {"WEOffsetToRun", (PyCFunction)wasteObj_WEOffsetToRun, 1,
1572 "(SInt32 offset) -> (SInt32 _rv)"},
1573 {"WEGetRunRange", (PyCFunction)wasteObj_WEGetRunRange, 1,
1574 "(SInt32 runIndex) -> (SInt32 runStart, SInt32 runEnd)"},
1575 {"WECountRuns", (PyCFunction)wasteObj_WECountRuns, 1,
1576 "() -> (SInt32 _rv)"},
Jack Jansen2268af51996-08-06 16:04:22 +00001577 {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1,
1578 "() -> (UInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001579 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001580 "(SInt32 selStart, SInt32 selEnd) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001581 {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1,
1582 "(LongRect destRect) -> None"},
1583 {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1,
1584 "(LongRect viewRect) -> None"},
1585 {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001586 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001587 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001588 "(SInt32 offset) -> (WERunInfo runInfo)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001589 {"WEGetRunDirection", (PyCFunction)wasteObj_WEGetRunDirection, 1,
1590 "(SInt32 offset) -> (Boolean _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001591 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001592 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001593 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001594 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001595 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001596 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001597 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001598 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001599 {"WEFindParagraph", (PyCFunction)wasteObj_WEFindParagraph, 1,
1600 "(SInt32 offset, WEEdge edge) -> (SInt32 paragraphStart, SInt32 paragraphEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001601 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001602 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001603 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1604 "() -> (WEAlignment _rv)"},
1605 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1606 "(WEAlignment alignment) -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00001607 {"WEGetDirection", (PyCFunction)wasteObj_WEGetDirection, 1,
1608 "() -> (WEDirection _rv)"},
1609 {"WESetDirection", (PyCFunction)wasteObj_WESetDirection, 1,
1610 "(WEDirection direction) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001611 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1612 "() -> None"},
1613 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1614 "(RgnHandle updateRgn) -> None"},
1615 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001616 "(SInt32 hOffset, SInt32 vOffset) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001617 {"WESelView", (PyCFunction)wasteObj_WESelView, 1,
1618 "() -> None"},
1619 {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1,
1620 "() -> None"},
1621 {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1,
1622 "() -> None"},
1623 {"WEKey", (PyCFunction)wasteObj_WEKey, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001624 "(SInt16 key, EventModifiers modifiers) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001625 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001626 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001627 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1628 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1629 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001630 "() -> (UInt32 maxSleep)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001631 {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1,
1632 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1633 {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1,
1634 "() -> None"},
1635 {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1,
1636 "(WEStyleMode mode, TextStyle ts) -> None"},
1637 {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1,
1638 "(StScrpHandle hStyles) -> None"},
1639 {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1,
1640 "(Handle hText) -> None"},
1641 {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1,
1642 "() -> None"},
1643 {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1,
1644 "() -> None"},
1645 {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1,
1646 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1647 {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1,
1648 "() -> (Boolean _rv)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001649 {"WEBeginAction", (PyCFunction)wasteObj_WEBeginAction, 1,
1650 "() -> None"},
1651 {"WEEndAction", (PyCFunction)wasteObj_WEEndAction, 1,
1652 "(WEActionKind actionKind) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001653 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001654 "() -> (UInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001655 {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1,
1656 "() -> None"},
1657 {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1,
1658 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1659 {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1,
1660 "() -> (WEObjectReference obj)"},
1661 {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001662 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001663 {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1,
1664 "(WESoupHandle hSoup) -> None"},
1665 {"WECut", (PyCFunction)wasteObj_WECut, 1,
1666 "() -> None"},
1667 {"WECopy", (PyCFunction)wasteObj_WECopy, 1,
1668 "() -> None"},
1669 {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1,
1670 "() -> None"},
1671 {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1,
1672 "() -> (Boolean _rv)"},
1673 {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001674 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001675 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001676 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001677 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001678 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001679 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1680 "() -> None"},
1681 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001682 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001683 {"WEGetUserInfo", (PyCFunction)wasteObj_WEGetUserInfo, 1,
1684 "(WESelector tag) -> (SInt32 userInfo)"},
1685 {"WESetUserInfo", (PyCFunction)wasteObj_WESetUserInfo, 1,
1686 "(WESelector tag, SInt32 userInfo) -> None"},
Jack Jansen176f3a91996-10-23 15:43:46 +00001687 {"WEInstallTabHooks", (PyCFunction)wasteObj_WEInstallTabHooks, 1,
1688 "() -> None"},
1689 {"WERemoveTabHooks", (PyCFunction)wasteObj_WERemoveTabHooks, 1,
1690 "() -> None"},
1691 {"WEIsTabHooks", (PyCFunction)wasteObj_WEIsTabHooks, 1,
1692 "() -> (Boolean _rv)"},
Jack Jansena4f03091998-03-02 16:56:18 +00001693 {"WEGetTabSize", (PyCFunction)wasteObj_WEGetTabSize, 1,
1694 "() -> (SInt16 _rv)"},
1695 {"WESetTabSize", (PyCFunction)wasteObj_WESetTabSize, 1,
1696 "(SInt16 tabWidth) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001697 {NULL, NULL, 0}
1698};
1699
1700PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1701
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001702static PyObject *wasteObj_getattr(wasteObject *self, char *name)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001703{
1704 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1705}
1706
1707#define wasteObj_setattr NULL
1708
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001709#define wasteObj_compare NULL
1710
1711#define wasteObj_repr NULL
1712
1713#define wasteObj_hash NULL
1714
Jack Jansen90ecdf41996-04-16 14:29:15 +00001715PyTypeObject waste_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +00001716 PyObject_HEAD_INIT(NULL)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001717 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +00001718 "waste.waste", /*tp_name*/
Jack Jansen90ecdf41996-04-16 14:29:15 +00001719 sizeof(wasteObject), /*tp_basicsize*/
1720 0, /*tp_itemsize*/
1721 /* methods */
1722 (destructor) wasteObj_dealloc, /*tp_dealloc*/
1723 0, /*tp_print*/
1724 (getattrfunc) wasteObj_getattr, /*tp_getattr*/
1725 (setattrfunc) wasteObj_setattr, /*tp_setattr*/
Jack Jansen9d8b96c2000-07-14 22:16:45 +00001726 (cmpfunc) wasteObj_compare, /*tp_compare*/
1727 (reprfunc) wasteObj_repr, /*tp_repr*/
1728 (PyNumberMethods *)0, /* tp_as_number */
1729 (PySequenceMethods *)0, /* tp_as_sequence */
1730 (PyMappingMethods *)0, /* tp_as_mapping */
1731 (hashfunc) wasteObj_hash, /*tp_hash*/
Jack Jansen90ecdf41996-04-16 14:29:15 +00001732};
1733
1734/* --------------------- End object type waste ---------------------- */
1735
1736
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001737static PyObject *waste_WENew(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001738{
1739 PyObject *_res = NULL;
1740 OSErr _err;
1741 LongRect destRect;
1742 LongRect viewRect;
Jack Jansen2268af51996-08-06 16:04:22 +00001743 UInt32 flags;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001744 WEReference we;
1745 if (!PyArg_ParseTuple(_args, "O&O&l",
1746 LongRect_Convert, &destRect,
1747 LongRect_Convert, &viewRect,
1748 &flags))
1749 return NULL;
1750 _err = WENew(&destRect,
1751 &viewRect,
1752 flags,
1753 &we);
1754 if (_err != noErr) return PyMac_Error(_err);
1755 _res = Py_BuildValue("O&",
1756 wasteObj_New, we);
1757 return _res;
1758}
1759
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001760static PyObject *waste_WEUpdateStyleScrap(PyObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001761{
1762 PyObject *_res = NULL;
1763 OSErr _err;
1764 StScrpHandle hStyles;
1765 WEFontTableHandle hFontTable;
1766 if (!PyArg_ParseTuple(_args, "O&O&",
1767 ResObj_Convert, &hStyles,
1768 ResObj_Convert, &hFontTable))
1769 return NULL;
1770 _err = WEUpdateStyleScrap(hStyles,
1771 hFontTable);
1772 if (_err != noErr) return PyMac_Error(_err);
1773 Py_INCREF(Py_None);
1774 _res = Py_None;
1775 return _res;
1776}
1777
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001778static PyObject *waste_WEInstallTSMHandlers(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001779{
1780 PyObject *_res = NULL;
1781 OSErr _err;
1782 if (!PyArg_ParseTuple(_args, ""))
1783 return NULL;
1784 _err = WEInstallTSMHandlers();
1785 if (_err != noErr) return PyMac_Error(_err);
1786 Py_INCREF(Py_None);
1787 _res = Py_None;
1788 return _res;
1789}
1790
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001791static PyObject *waste_WERemoveTSMHandlers(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001792{
1793 PyObject *_res = NULL;
1794 OSErr _err;
1795 if (!PyArg_ParseTuple(_args, ""))
1796 return NULL;
1797 _err = WERemoveTSMHandlers();
1798 if (_err != noErr) return PyMac_Error(_err);
1799 Py_INCREF(Py_None);
1800 _res = Py_None;
1801 return _res;
1802}
1803
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001804static PyObject *waste_WEHandleTSMEvent(PyObject *_self, PyObject *_args)
Jack Jansen2369a981998-02-20 15:57:30 +00001805{
1806 PyObject *_res = NULL;
1807 OSErr _err;
1808 AppleEvent ae;
1809 AppleEvent reply;
1810 if (!PyArg_ParseTuple(_args, "O&",
1811 AEDesc_Convert, &ae))
1812 return NULL;
1813 _err = WEHandleTSMEvent(&ae,
1814 &reply);
1815 if (_err != noErr) return PyMac_Error(_err);
1816 _res = Py_BuildValue("O&",
1817 AEDesc_New, &reply);
1818 return _res;
1819}
1820
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001821static PyObject *waste_WELongPointToPoint(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001822{
1823 PyObject *_res = NULL;
1824 LongPt lp;
1825 Point p;
1826 if (!PyArg_ParseTuple(_args, "O&",
1827 LongPt_Convert, &lp))
1828 return NULL;
1829 WELongPointToPoint(&lp,
1830 &p);
1831 _res = Py_BuildValue("O&",
1832 PyMac_BuildPoint, p);
1833 return _res;
1834}
1835
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001836static PyObject *waste_WEPointToLongPoint(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001837{
1838 PyObject *_res = NULL;
1839 Point p;
1840 LongPt lp;
1841 if (!PyArg_ParseTuple(_args, "O&",
1842 PyMac_GetPoint, &p))
1843 return NULL;
1844 WEPointToLongPoint(p,
1845 &lp);
1846 _res = Py_BuildValue("O&",
1847 LongPt_New, &lp);
1848 return _res;
1849}
1850
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001851static PyObject *waste_WESetLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001852{
1853 PyObject *_res = NULL;
1854 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001855 SInt32 left;
1856 SInt32 top;
1857 SInt32 right;
1858 SInt32 bottom;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001859 if (!PyArg_ParseTuple(_args, "llll",
1860 &left,
1861 &top,
1862 &right,
1863 &bottom))
1864 return NULL;
1865 WESetLongRect(&lr,
1866 left,
1867 top,
1868 right,
1869 bottom);
1870 _res = Py_BuildValue("O&",
1871 LongRect_New, &lr);
1872 return _res;
1873}
1874
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001875static PyObject *waste_WELongRectToRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001876{
1877 PyObject *_res = NULL;
1878 LongRect lr;
1879 Rect r;
1880 if (!PyArg_ParseTuple(_args, "O&",
1881 LongRect_Convert, &lr))
1882 return NULL;
1883 WELongRectToRect(&lr,
1884 &r);
1885 _res = Py_BuildValue("O&",
1886 PyMac_BuildRect, &r);
1887 return _res;
1888}
1889
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001890static PyObject *waste_WERectToLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001891{
1892 PyObject *_res = NULL;
1893 Rect r;
1894 LongRect lr;
1895 if (!PyArg_ParseTuple(_args, "O&",
1896 PyMac_GetRect, &r))
1897 return NULL;
1898 WERectToLongRect(&r,
1899 &lr);
1900 _res = Py_BuildValue("O&",
1901 LongRect_New, &lr);
1902 return _res;
1903}
1904
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001905static PyObject *waste_WEOffsetLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001906{
1907 PyObject *_res = NULL;
1908 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00001909 SInt32 hOffset;
1910 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001911 if (!PyArg_ParseTuple(_args, "ll",
1912 &hOffset,
1913 &vOffset))
1914 return NULL;
1915 WEOffsetLongRect(&lr,
1916 hOffset,
1917 vOffset);
1918 _res = Py_BuildValue("O&",
1919 LongRect_New, &lr);
1920 return _res;
1921}
1922
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001923static PyObject *waste_WELongPointInLongRect(PyObject *_self, PyObject *_args)
Jack Jansen90ecdf41996-04-16 14:29:15 +00001924{
1925 PyObject *_res = NULL;
1926 Boolean _rv;
1927 LongPt lp;
1928 LongRect lr;
1929 if (!PyArg_ParseTuple(_args, "O&O&",
1930 LongPt_Convert, &lp,
1931 LongRect_Convert, &lr))
1932 return NULL;
1933 _rv = WELongPointInLongRect(&lp,
1934 &lr);
1935 _res = Py_BuildValue("b",
1936 _rv);
1937 return _res;
1938}
1939
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001940static PyObject *waste_STDObjectHandlers(PyObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +00001941{
1942 PyObject *_res = NULL;
1943
1944 OSErr err;
1945 // install the sample object handlers for pictures and sounds
1946#define kTypePicture 'PICT'
1947#define kTypeSound 'snd '
1948
1949 if ( !PyArg_ParseTuple(_args, "") ) return NULL;
1950
1951 if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
1952 (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
1953 goto cleanup;
1954
1955 if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
1956 (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
1957 goto cleanup;
1958
1959 if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
1960 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
1961 goto cleanup;
1962
1963 if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
1964 (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
1965 goto cleanup;
1966
1967 if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
1968 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
1969 goto cleanup;
1970
1971 if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
1972 (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
1973 goto cleanup;
1974 Py_INCREF(Py_None);
1975 return Py_None;
1976
1977 cleanup:
1978 return PyMac_Error(err);
1979
1980}
1981
Jack Jansenfa77e1a2001-05-22 21:56:42 +00001982static PyObject *waste_WEInstallObjectHandler(PyObject *_self, PyObject *_args)
Jack Jansen756522f1996-05-07 15:24:01 +00001983{
1984 PyObject *_res = NULL;
1985
1986 OSErr err;
1987 FlavorType objectType;
1988 WESelector selector;
1989 PyObject *py_handler;
1990 UniversalProcPtr handler;
1991 WEReference we = NULL;
1992 PyObject *key;
1993
1994
1995 if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
1996 PyMac_GetOSType, &objectType,
1997 PyMac_GetOSType, &selector,
1998 &py_handler,
Jack Jansen7df36061996-10-01 11:41:14 +00001999 WEOObj_Convert, &we) ) return NULL;
Jack Jansen756522f1996-05-07 15:24:01 +00002000
Jack Jansen25241d91996-05-20 11:30:45 +00002001 if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
2002 else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
2003 else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
2004 else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +00002005 else return PyMac_Error(weUndefinedSelectorErr);
2006
2007 if ((key = Py_BuildValue("O&O&",
2008 PyMac_BuildOSType, objectType,
2009 PyMac_BuildOSType, selector)) == NULL )
2010 return NULL;
2011
2012 PyDict_SetItem(callbackdict, key, py_handler);
2013
2014 err = WEInstallObjectHandler(objectType, selector, handler, we);
2015 if ( err ) return PyMac_Error(err);
2016 Py_INCREF(Py_None);
2017 return Py_None;
2018
2019}
2020
Jack Jansen90ecdf41996-04-16 14:29:15 +00002021static PyMethodDef waste_methods[] = {
2022 {"WENew", (PyCFunction)waste_WENew, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002023 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
Jack Jansen2369a981998-02-20 15:57:30 +00002024 {"WEUpdateStyleScrap", (PyCFunction)waste_WEUpdateStyleScrap, 1,
2025 "(StScrpHandle hStyles, WEFontTableHandle hFontTable) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002026 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
2027 "() -> None"},
2028 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
2029 "() -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00002030 {"WEHandleTSMEvent", (PyCFunction)waste_WEHandleTSMEvent, 1,
2031 "(AppleEvent ae) -> (AppleEvent reply)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002032 {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1,
2033 "(LongPt lp) -> (Point p)"},
2034 {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1,
2035 "(Point p) -> (LongPt lp)"},
2036 {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002037 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002038 {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1,
2039 "(LongRect lr) -> (Rect r)"},
2040 {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1,
2041 "(Rect r) -> (LongRect lr)"},
2042 {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002043 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002044 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
2045 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +00002046 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
2047 NULL},
2048 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
2049 NULL},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002050 {NULL, NULL, 0}
2051};
2052
2053
2054
Jack Jansen756522f1996-05-07 15:24:01 +00002055/* Return the object corresponding to the window, or NULL */
2056
2057PyObject *
2058ExistingwasteObj_New(w)
2059 WEReference w;
2060{
2061 PyObject *it = NULL;
2062
2063 if (w == NULL)
2064 it = NULL;
2065 else
2066 WEGetInfo(weRefCon, (void *)&it, w);
2067 if (it == NULL || ((wasteObject *)it)->ob_itself != w)
2068 it = Py_None;
2069 Py_INCREF(it);
2070 return it;
2071}
2072
Jack Jansen90ecdf41996-04-16 14:29:15 +00002073
Jack Jansenfa77e1a2001-05-22 21:56:42 +00002074void initwaste(void)
Jack Jansen90ecdf41996-04-16 14:29:15 +00002075{
2076 PyObject *m;
2077 PyObject *d;
2078
2079
2080
2081
2082 m = Py_InitModule("waste", waste_methods);
2083 d = PyModule_GetDict(m);
2084 waste_Error = PyMac_GetOSErrException();
2085 if (waste_Error == NULL ||
2086 PyDict_SetItemString(d, "Error", waste_Error) != 0)
Jack Jansen97ed9072000-09-08 22:06:16 +00002087 return;
Jack Jansena755e681997-09-20 17:40:22 +00002088 WEO_Type.ob_type = &PyType_Type;
2089 Py_INCREF(&WEO_Type);
2090 if (PyDict_SetItemString(d, "WEOType", (PyObject *)&WEO_Type) != 0)
2091 Py_FatalError("can't initialize WEOType");
2092 waste_Type.ob_type = &PyType_Type;
2093 Py_INCREF(&waste_Type);
2094 if (PyDict_SetItemString(d, "wasteType", (PyObject *)&waste_Type) != 0)
2095 Py_FatalError("can't initialize wasteType");
Jack Jansen756522f1996-05-07 15:24:01 +00002096
2097 callbackdict = PyDict_New();
2098 if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
Jack Jansen97ed9072000-09-08 22:06:16 +00002099 return;
Jack Jansen756522f1996-05-07 15:24:01 +00002100 upp_new_handler = NewWENewObjectProc(my_new_handler);
Jack Jansen25241d91996-05-20 11:30:45 +00002101 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
2102 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
2103 upp_click_handler = NewWEClickObjectProc(my_click_handler);
Jack Jansen756522f1996-05-07 15:24:01 +00002104
2105
Jack Jansen90ecdf41996-04-16 14:29:15 +00002106}
2107
2108/* ======================== End module waste ======================== */
2109