blob: ffb39c3f74982b42ace14077066536efb0c14e93 [file] [log] [blame]
Jack Jansen90ecdf41996-04-16 14:29:15 +00001
2/* ========================== Module waste ========================== */
3
4#include "Python.h"
5
6
7
8#define SystemSevenOrLater 1
9
10#include "macglue.h"
11#include <Memory.h>
12#include <Dialogs.h>
13#include <Menus.h>
14#include <Controls.h>
15
16extern PyObject *ResObj_New(Handle);
17extern int ResObj_Convert(PyObject *, Handle *);
18extern PyObject *OptResObj_New(Handle);
19extern int OptResObj_Convert(PyObject *, Handle *);
20
21extern PyObject *WinObj_New(WindowPtr);
22extern int WinObj_Convert(PyObject *, WindowPtr *);
23extern PyTypeObject Window_Type;
24#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
25
26extern PyObject *DlgObj_New(DialogPtr);
27extern int DlgObj_Convert(PyObject *, DialogPtr *);
28extern PyTypeObject Dialog_Type;
29#define DlgObj_Check(x) ((x)->ob_type == &Dialog_Type)
30
31extern PyObject *MenuObj_New(MenuHandle);
32extern int MenuObj_Convert(PyObject *, MenuHandle *);
33
34extern PyObject *CtlObj_New(ControlHandle);
35extern int CtlObj_Convert(PyObject *, ControlHandle *);
36
37extern PyObject *GrafObj_New(GrafPtr);
38extern int GrafObj_Convert(PyObject *, GrafPtr *);
39
40extern PyObject *BMObj_New(BitMapPtr);
41extern int BMObj_Convert(PyObject *, BitMapPtr *);
42
Jack Jansen90ecdf41996-04-16 14:29:15 +000043extern PyObject *WinObj_WhichWindow(WindowPtr);
44
45#include <WASTE.h>
Jack Jansen8505ef81997-08-27 14:09:25 +000046#include <WEObjectHandlers.h>
Jack Jansena755e681997-09-20 17:40:22 +000047#include <WETabs.h>
Jack Jansen90ecdf41996-04-16 14:29:15 +000048
49/* Exported by Qdmodule.c: */
50extern PyObject *QdRGB_New(RGBColor *);
51extern int QdRGB_Convert(PyObject *, RGBColor *);
52
Jack Jansen8505ef81997-08-27 14:09:25 +000053/* Exported by AEModule.c: */
54extern PyObject *AEDesc_New(AppleEvent *);
55extern int AEDesc_Convert(PyObject *, AppleEvent *);
56
Jack Jansen90ecdf41996-04-16 14:29:15 +000057/* Forward declaration */
58staticforward PyObject *WEOObj_New(WEObjectReference);
Jack Jansen756522f1996-05-07 15:24:01 +000059staticforward PyObject *ExistingwasteObj_New(WEReference);
Jack Jansen90ecdf41996-04-16 14:29:15 +000060
61/*
62** Parse/generate TextStyle records
63*/
64static
65PyObject *TextStyle_New(itself)
66 TextStylePtr itself;
67{
68
69 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
70 &itself->tsColor);
71}
72
73static
74TextStyle_Convert(v, p_itself)
75 PyObject *v;
76 TextStylePtr p_itself;
77{
78 long font, face, size;
79
80 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
81 return 0;
82 p_itself->tsFont = (short)font;
83 p_itself->tsFace = (Style)face;
84 p_itself->tsSize = (short)size;
85 return 1;
86}
87
88/*
89** Parse/generate RunInfo records
90*/
91static
92PyObject *RunInfo_New(itself)
93 WERunInfo *itself;
94{
95
96 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
97 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
98}
99
100/* Conversion of long points and rects */
101int
102LongRect_Convert(PyObject *v, LongRect *r)
103{
104 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
105}
106
107PyObject *
108LongRect_New(LongRect *r)
109{
110 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
111}
112
113
114LongPt_Convert(PyObject *v, LongPt *p)
115{
116 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
117}
118
119PyObject *
120LongPt_New(LongPt *p)
121{
122 return Py_BuildValue("(ll)", p->h, p->v);
123}
124
Jack Jansen756522f1996-05-07 15:24:01 +0000125/* Stuff for the callbacks: */
126static PyObject *callbackdict;
Jack Jansen25241d91996-05-20 11:30:45 +0000127WENewObjectUPP upp_new_handler;
128WEDisposeObjectUPP upp_dispose_handler;
129WEDrawObjectUPP upp_draw_handler;
130WEClickObjectUPP upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +0000131
132static OSErr
133any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
134{
135 FlavorType tp;
136 PyObject *key, *func;
137
138 if ( args == NULL ) return errAECorruptData;
139
140 tp = WEGetObjectType(who);
141
142 if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
143 return errAECorruptData;
144 if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
145 Py_DECREF(key);
146 return errAEHandlerNotFound;
147 }
148 Py_INCREF(func);
149 *rv = PyEval_CallObject(func, args);
150 Py_DECREF(func);
151 Py_DECREF(key);
152 if ( *rv == NULL ) {
Jack Jansendeff89c1998-10-12 20:53:15 +0000153 PySys_WriteStderr("--Exception in callback: ");
Jack Jansen756522f1996-05-07 15:24:01 +0000154 PyErr_Print();
155 return errAEReplyNotArrived;
156 }
157 return 0;
158}
159
160static pascal OSErr
161my_new_handler(Point *objectSize, WEObjectReference objref)
162{
163 PyObject *args=NULL, *rv=NULL;
164 OSErr err;
165
166 args=Py_BuildValue("(O&)", WEOObj_New, objref);
167 err = any_handler(weNewHandler, objref, args, &rv);
168 if (!err) {
169 if (!PyMac_GetPoint(rv, objectSize) )
170 err = errAECoercionFail;
171 }
172 if ( args ) Py_DECREF(args);
173 if ( rv ) Py_DECREF(rv);
174 return err;
175}
176
177static pascal OSErr
178my_dispose_handler(WEObjectReference objref)
179{
180 PyObject *args=NULL, *rv=NULL;
181 OSErr err;
182
183 args=Py_BuildValue("(O&)", WEOObj_New, objref);
184 err = any_handler(weDisposeHandler, objref, args, &rv);
185 if ( args ) Py_DECREF(args);
186 if ( rv ) Py_DECREF(rv);
187 return err;
188}
189
190static pascal OSErr
191my_draw_handler(Rect *destRect, WEObjectReference objref)
192{
193 PyObject *args=NULL, *rv=NULL;
194 OSErr err;
195
196 args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
197 err = any_handler(weDrawHandler, objref, args, &rv);
198 if ( args ) Py_DECREF(args);
199 if ( rv ) Py_DECREF(rv);
200 return err;
201}
202
203static pascal Boolean
204my_click_handler(Point hitPt, EventModifiers modifiers,
205 unsigned long clickTime, WEObjectReference objref)
206{
207 PyObject *args=NULL, *rv=NULL;
208 int retvalue;
209 OSErr err;
210
211 args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
212 (long)modifiers, (long)clickTime, WEOObj_New, objref);
213 err = any_handler(weClickHandler, objref, args, &rv);
214 if (!err)
215 retvalue = PyInt_AsLong(rv);
216 else
217 retvalue = 0;
218 if ( args ) Py_DECREF(args);
219 if ( rv ) Py_DECREF(rv);
220 return retvalue;
221}
222
223
224
Jack Jansen90ecdf41996-04-16 14:29:15 +0000225static PyObject *waste_Error;
226
227/* ------------------------ Object type WEO ------------------------- */
228
229PyTypeObject WEO_Type;
230
231#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
232
233typedef struct WEOObject {
234 PyObject_HEAD
235 WEObjectReference ob_itself;
236} WEOObject;
237
238PyObject *WEOObj_New(itself)
239 WEObjectReference itself;
240{
241 WEOObject *it;
242 if (itself == NULL) {
243 Py_INCREF(Py_None);
244 return Py_None;
245 }
246 it = PyObject_NEW(WEOObject, &WEO_Type);
247 if (it == NULL) return NULL;
248 it->ob_itself = itself;
249 return (PyObject *)it;
250}
251WEOObj_Convert(v, p_itself)
252 PyObject *v;
253 WEObjectReference *p_itself;
254{
255 if (!WEOObj_Check(v))
256 {
257 PyErr_SetString(PyExc_TypeError, "WEO required");
258 return 0;
259 }
260 *p_itself = ((WEOObject *)v)->ob_itself;
261 return 1;
262}
263
264static void WEOObj_dealloc(self)
265 WEOObject *self;
266{
267 /* Cleanup of self->ob_itself goes here */
268 PyMem_DEL(self);
269}
270
271static PyObject *WEOObj_WEGetObjectType(_self, _args)
272 WEOObject *_self;
273 PyObject *_args;
274{
275 PyObject *_res = NULL;
276 FlavorType _rv;
277 if (!PyArg_ParseTuple(_args, ""))
278 return NULL;
279 _rv = WEGetObjectType(_self->ob_itself);
280 _res = Py_BuildValue("O&",
281 PyMac_BuildOSType, _rv);
282 return _res;
283}
284
285static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args)
286 WEOObject *_self;
287 PyObject *_args;
288{
289 PyObject *_res = NULL;
290 Handle _rv;
291 if (!PyArg_ParseTuple(_args, ""))
292 return NULL;
293 _rv = WEGetObjectDataHandle(_self->ob_itself);
294 _res = Py_BuildValue("O&",
295 ResObj_New, _rv);
296 return _res;
297}
298
299static PyObject *WEOObj_WEGetObjectSize(_self, _args)
300 WEOObject *_self;
301 PyObject *_args;
302{
303 PyObject *_res = NULL;
304 Point _rv;
305 if (!PyArg_ParseTuple(_args, ""))
306 return NULL;
307 _rv = WEGetObjectSize(_self->ob_itself);
308 _res = Py_BuildValue("O&",
309 PyMac_BuildPoint, _rv);
310 return _res;
311}
312
Jack Jansen756522f1996-05-07 15:24:01 +0000313static PyObject *WEOObj_WEGetObjectOwner(_self, _args)
314 WEOObject *_self;
315 PyObject *_args;
316{
317 PyObject *_res = NULL;
318 WEReference _rv;
319 if (!PyArg_ParseTuple(_args, ""))
320 return NULL;
321 _rv = WEGetObjectOwner(_self->ob_itself);
322 _res = Py_BuildValue("O&",
323 ExistingwasteObj_New, _rv);
324 return _res;
325}
326
Jack Jansen90ecdf41996-04-16 14:29:15 +0000327static PyObject *WEOObj_WEGetObjectRefCon(_self, _args)
328 WEOObject *_self;
329 PyObject *_args;
330{
331 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000332 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000333 if (!PyArg_ParseTuple(_args, ""))
334 return NULL;
335 _rv = WEGetObjectRefCon(_self->ob_itself);
336 _res = Py_BuildValue("l",
337 _rv);
338 return _res;
339}
340
341static PyObject *WEOObj_WESetObjectRefCon(_self, _args)
342 WEOObject *_self;
343 PyObject *_args;
344{
345 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000346 SInt32 refCon;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000347 if (!PyArg_ParseTuple(_args, "l",
348 &refCon))
349 return NULL;
350 WESetObjectRefCon(_self->ob_itself,
351 refCon);
352 Py_INCREF(Py_None);
353 _res = Py_None;
354 return _res;
355}
356
357static PyMethodDef WEOObj_methods[] = {
358 {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1,
359 "() -> (FlavorType _rv)"},
360 {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1,
361 "() -> (Handle _rv)"},
362 {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1,
363 "() -> (Point _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +0000364 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
365 "() -> (WEReference _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000366 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000367 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000368 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
Jack Jansen2268af51996-08-06 16:04:22 +0000369 "(SInt32 refCon) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000370 {NULL, NULL, 0}
371};
372
373PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
374
375static PyObject *WEOObj_getattr(self, name)
376 WEOObject *self;
377 char *name;
378{
379 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
380}
381
382#define WEOObj_setattr NULL
383
384PyTypeObject WEO_Type = {
385 PyObject_HEAD_INIT(&PyType_Type)
386 0, /*ob_size*/
387 "WEO", /*tp_name*/
388 sizeof(WEOObject), /*tp_basicsize*/
389 0, /*tp_itemsize*/
390 /* methods */
391 (destructor) WEOObj_dealloc, /*tp_dealloc*/
392 0, /*tp_print*/
393 (getattrfunc) WEOObj_getattr, /*tp_getattr*/
394 (setattrfunc) WEOObj_setattr, /*tp_setattr*/
395};
396
397/* ---------------------- End object type WEO ----------------------- */
398
399
400/* ----------------------- Object type waste ------------------------ */
401
402PyTypeObject waste_Type;
403
404#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
405
406typedef struct wasteObject {
407 PyObject_HEAD
408 WEReference ob_itself;
409} wasteObject;
410
411PyObject *wasteObj_New(itself)
412 WEReference itself;
413{
414 wasteObject *it;
415 if (itself == NULL) {
416 PyErr_SetString(waste_Error,"Cannot create null WE");
417 return NULL;
418 }
419 it = PyObject_NEW(wasteObject, &waste_Type);
420 if (it == NULL) return NULL;
421 it->ob_itself = itself;
Jack Jansen756522f1996-05-07 15:24:01 +0000422 WESetInfo(weRefCon, (void *)&it, itself);
Jack Jansen90ecdf41996-04-16 14:29:15 +0000423 return (PyObject *)it;
424}
425wasteObj_Convert(v, p_itself)
426 PyObject *v;
427 WEReference *p_itself;
428{
429 if (!wasteObj_Check(v))
430 {
431 PyErr_SetString(PyExc_TypeError, "waste required");
432 return 0;
433 }
434 *p_itself = ((wasteObject *)v)->ob_itself;
435 return 1;
436}
437
438static void wasteObj_dealloc(self)
439 wasteObject *self;
440{
441 WEDispose(self->ob_itself);
442 PyMem_DEL(self);
443}
444
445static PyObject *wasteObj_WEGetText(_self, _args)
446 wasteObject *_self;
447 PyObject *_args;
448{
449 PyObject *_res = NULL;
450 Handle _rv;
451 if (!PyArg_ParseTuple(_args, ""))
452 return NULL;
453 _rv = WEGetText(_self->ob_itself);
454 _res = Py_BuildValue("O&",
455 ResObj_New, _rv);
456 return _res;
457}
458
459static PyObject *wasteObj_WEGetChar(_self, _args)
460 wasteObject *_self;
461 PyObject *_args;
462{
463 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000464 SInt16 _rv;
465 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000466 if (!PyArg_ParseTuple(_args, "l",
467 &offset))
468 return NULL;
469 _rv = WEGetChar(offset,
470 _self->ob_itself);
471 _res = Py_BuildValue("h",
472 _rv);
473 return _res;
474}
475
476static PyObject *wasteObj_WEGetTextLength(_self, _args)
477 wasteObject *_self;
478 PyObject *_args;
479{
480 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000481 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000482 if (!PyArg_ParseTuple(_args, ""))
483 return NULL;
484 _rv = WEGetTextLength(_self->ob_itself);
485 _res = Py_BuildValue("l",
486 _rv);
487 return _res;
488}
489
Jack Jansen90ecdf41996-04-16 14:29:15 +0000490static PyObject *wasteObj_WEGetHeight(_self, _args)
491 wasteObject *_self;
492 PyObject *_args;
493{
494 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000495 SInt32 _rv;
496 SInt32 startLine;
497 SInt32 endLine;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000498 if (!PyArg_ParseTuple(_args, "ll",
499 &startLine,
500 &endLine))
501 return NULL;
502 _rv = WEGetHeight(startLine,
503 endLine,
504 _self->ob_itself);
505 _res = Py_BuildValue("l",
506 _rv);
507 return _res;
508}
509
510static PyObject *wasteObj_WEGetSelection(_self, _args)
511 wasteObject *_self;
512 PyObject *_args;
513{
514 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000515 SInt32 selStart;
516 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000517 if (!PyArg_ParseTuple(_args, ""))
518 return NULL;
519 WEGetSelection(&selStart,
520 &selEnd,
521 _self->ob_itself);
522 _res = Py_BuildValue("ll",
523 selStart,
524 selEnd);
525 return _res;
526}
527
528static PyObject *wasteObj_WEGetDestRect(_self, _args)
529 wasteObject *_self;
530 PyObject *_args;
531{
532 PyObject *_res = NULL;
533 LongRect destRect;
534 if (!PyArg_ParseTuple(_args, ""))
535 return NULL;
536 WEGetDestRect(&destRect,
537 _self->ob_itself);
538 _res = Py_BuildValue("O&",
539 LongRect_New, &destRect);
540 return _res;
541}
542
543static PyObject *wasteObj_WEGetViewRect(_self, _args)
544 wasteObject *_self;
545 PyObject *_args;
546{
547 PyObject *_res = NULL;
548 LongRect viewRect;
549 if (!PyArg_ParseTuple(_args, ""))
550 return NULL;
551 WEGetViewRect(&viewRect,
552 _self->ob_itself);
553 _res = Py_BuildValue("O&",
554 LongRect_New, &viewRect);
555 return _res;
556}
557
558static PyObject *wasteObj_WEIsActive(_self, _args)
559 wasteObject *_self;
560 PyObject *_args;
561{
562 PyObject *_res = NULL;
563 Boolean _rv;
564 if (!PyArg_ParseTuple(_args, ""))
565 return NULL;
566 _rv = WEIsActive(_self->ob_itself);
567 _res = Py_BuildValue("b",
568 _rv);
569 return _res;
570}
571
572static PyObject *wasteObj_WEOffsetToLine(_self, _args)
573 wasteObject *_self;
574 PyObject *_args;
575{
576 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000577 SInt32 _rv;
578 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000579 if (!PyArg_ParseTuple(_args, "l",
580 &offset))
581 return NULL;
582 _rv = WEOffsetToLine(offset,
583 _self->ob_itself);
584 _res = Py_BuildValue("l",
585 _rv);
586 return _res;
587}
588
589static PyObject *wasteObj_WEGetLineRange(_self, _args)
590 wasteObject *_self;
591 PyObject *_args;
592{
593 PyObject *_res = NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000594 SInt32 lineIndex;
Jack Jansen2268af51996-08-06 16:04:22 +0000595 SInt32 lineStart;
596 SInt32 lineEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000597 if (!PyArg_ParseTuple(_args, "l",
Jack Jansen2369a981998-02-20 15:57:30 +0000598 &lineIndex))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000599 return NULL;
Jack Jansen2369a981998-02-20 15:57:30 +0000600 WEGetLineRange(lineIndex,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000601 &lineStart,
602 &lineEnd,
603 _self->ob_itself);
604 _res = Py_BuildValue("ll",
605 lineStart,
606 lineEnd);
607 return _res;
608}
609
Jack Jansen2369a981998-02-20 15:57:30 +0000610static PyObject *wasteObj_WECountLines(_self, _args)
611 wasteObject *_self;
612 PyObject *_args;
613{
614 PyObject *_res = NULL;
615 SInt32 _rv;
616 if (!PyArg_ParseTuple(_args, ""))
617 return NULL;
618 _rv = WECountLines(_self->ob_itself);
619 _res = Py_BuildValue("l",
620 _rv);
621 return _res;
622}
623
624static PyObject *wasteObj_WEOffsetToRun(_self, _args)
625 wasteObject *_self;
626 PyObject *_args;
627{
628 PyObject *_res = NULL;
629 SInt32 _rv;
630 SInt32 offset;
631 if (!PyArg_ParseTuple(_args, "l",
632 &offset))
633 return NULL;
634 _rv = WEOffsetToRun(offset,
635 _self->ob_itself);
636 _res = Py_BuildValue("l",
637 _rv);
638 return _res;
639}
640
641static PyObject *wasteObj_WEGetRunRange(_self, _args)
642 wasteObject *_self;
643 PyObject *_args;
644{
645 PyObject *_res = NULL;
646 SInt32 runIndex;
647 SInt32 runStart;
648 SInt32 runEnd;
649 if (!PyArg_ParseTuple(_args, "l",
650 &runIndex))
651 return NULL;
652 WEGetRunRange(runIndex,
653 &runStart,
654 &runEnd,
655 _self->ob_itself);
656 _res = Py_BuildValue("ll",
657 runStart,
658 runEnd);
659 return _res;
660}
661
662static PyObject *wasteObj_WECountRuns(_self, _args)
663 wasteObject *_self;
664 PyObject *_args;
665{
666 PyObject *_res = NULL;
667 SInt32 _rv;
668 if (!PyArg_ParseTuple(_args, ""))
669 return NULL;
670 _rv = WECountRuns(_self->ob_itself);
671 _res = Py_BuildValue("l",
672 _rv);
673 return _res;
674}
675
Jack Jansen2268af51996-08-06 16:04:22 +0000676static PyObject *wasteObj_WEGetClickCount(_self, _args)
677 wasteObject *_self;
678 PyObject *_args;
679{
680 PyObject *_res = NULL;
681 UInt16 _rv;
682 if (!PyArg_ParseTuple(_args, ""))
683 return NULL;
684 _rv = WEGetClickCount(_self->ob_itself);
685 _res = Py_BuildValue("h",
686 _rv);
687 return _res;
688}
689
Jack Jansen90ecdf41996-04-16 14:29:15 +0000690static PyObject *wasteObj_WESetSelection(_self, _args)
691 wasteObject *_self;
692 PyObject *_args;
693{
694 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000695 SInt32 selStart;
696 SInt32 selEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000697 if (!PyArg_ParseTuple(_args, "ll",
698 &selStart,
699 &selEnd))
700 return NULL;
701 WESetSelection(selStart,
702 selEnd,
703 _self->ob_itself);
704 Py_INCREF(Py_None);
705 _res = Py_None;
706 return _res;
707}
708
709static PyObject *wasteObj_WESetDestRect(_self, _args)
710 wasteObject *_self;
711 PyObject *_args;
712{
713 PyObject *_res = NULL;
714 LongRect destRect;
715 if (!PyArg_ParseTuple(_args, "O&",
716 LongRect_Convert, &destRect))
717 return NULL;
718 WESetDestRect(&destRect,
719 _self->ob_itself);
720 Py_INCREF(Py_None);
721 _res = Py_None;
722 return _res;
723}
724
725static PyObject *wasteObj_WESetViewRect(_self, _args)
726 wasteObject *_self;
727 PyObject *_args;
728{
729 PyObject *_res = NULL;
730 LongRect viewRect;
731 if (!PyArg_ParseTuple(_args, "O&",
732 LongRect_Convert, &viewRect))
733 return NULL;
734 WESetViewRect(&viewRect,
735 _self->ob_itself);
736 Py_INCREF(Py_None);
737 _res = Py_None;
738 return _res;
739}
740
741static PyObject *wasteObj_WEContinuousStyle(_self, _args)
742 wasteObject *_self;
743 PyObject *_args;
744{
745 PyObject *_res = NULL;
746 Boolean _rv;
747 WEStyleMode mode;
748 TextStyle ts;
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000749 if (!PyArg_ParseTuple(_args, "h",
750 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000751 return NULL;
752 _rv = WEContinuousStyle(&mode,
753 &ts,
754 _self->ob_itself);
755 _res = Py_BuildValue("bhO&",
756 _rv,
757 mode,
758 TextStyle_New, &ts);
759 return _res;
760}
761
762static PyObject *wasteObj_WEGetRunInfo(_self, _args)
763 wasteObject *_self;
764 PyObject *_args;
765{
766 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000767 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000768 WERunInfo runInfo;
769 if (!PyArg_ParseTuple(_args, "l",
770 &offset))
771 return NULL;
772 WEGetRunInfo(offset,
773 &runInfo,
774 _self->ob_itself);
775 _res = Py_BuildValue("O&",
776 RunInfo_New, &runInfo);
777 return _res;
778}
779
Jack Jansen2369a981998-02-20 15:57:30 +0000780static PyObject *wasteObj_WEGetRunDirection(_self, _args)
781 wasteObject *_self;
782 PyObject *_args;
783{
784 PyObject *_res = NULL;
785 Boolean _rv;
786 SInt32 offset;
787 if (!PyArg_ParseTuple(_args, "l",
788 &offset))
789 return NULL;
790 _rv = WEGetRunDirection(offset,
791 _self->ob_itself);
792 _res = Py_BuildValue("b",
793 _rv);
794 return _res;
795}
796
Jack Jansen90ecdf41996-04-16 14:29:15 +0000797static PyObject *wasteObj_WEGetOffset(_self, _args)
798 wasteObject *_self;
799 PyObject *_args;
800{
801 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000802 SInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000803 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000804 WEEdge edge;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000805 if (!PyArg_ParseTuple(_args, "O&",
806 LongPt_Convert, &thePoint))
807 return NULL;
808 _rv = WEGetOffset(&thePoint,
809 &edge,
810 _self->ob_itself);
Jack Jansen2268af51996-08-06 16:04:22 +0000811 _res = Py_BuildValue("lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000812 _rv,
813 edge);
814 return _res;
815}
816
817static PyObject *wasteObj_WEGetPoint(_self, _args)
818 wasteObject *_self;
819 PyObject *_args;
820{
821 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000822 SInt32 offset;
823 SInt16 direction;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000824 LongPt thePoint;
Jack Jansen2268af51996-08-06 16:04:22 +0000825 SInt16 lineHeight;
826 if (!PyArg_ParseTuple(_args, "lh",
827 &offset,
828 &direction))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000829 return NULL;
830 WEGetPoint(offset,
Jack Jansen2268af51996-08-06 16:04:22 +0000831 direction,
Jack Jansen90ecdf41996-04-16 14:29:15 +0000832 &thePoint,
833 &lineHeight,
834 _self->ob_itself);
835 _res = Py_BuildValue("O&h",
836 LongPt_New, &thePoint,
837 lineHeight);
838 return _res;
839}
840
841static PyObject *wasteObj_WEFindWord(_self, _args)
842 wasteObject *_self;
843 PyObject *_args;
844{
845 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000846 SInt32 offset;
847 WEEdge edge;
848 SInt32 wordStart;
849 SInt32 wordEnd;
850 if (!PyArg_ParseTuple(_args, "lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000851 &offset,
852 &edge))
853 return NULL;
854 WEFindWord(offset,
855 edge,
856 &wordStart,
857 &wordEnd,
858 _self->ob_itself);
859 _res = Py_BuildValue("ll",
860 wordStart,
861 wordEnd);
862 return _res;
863}
864
865static PyObject *wasteObj_WEFindLine(_self, _args)
866 wasteObject *_self;
867 PyObject *_args;
868{
869 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +0000870 SInt32 offset;
871 WEEdge edge;
872 SInt32 lineStart;
873 SInt32 lineEnd;
874 if (!PyArg_ParseTuple(_args, "lb",
Jack Jansen90ecdf41996-04-16 14:29:15 +0000875 &offset,
876 &edge))
877 return NULL;
878 WEFindLine(offset,
879 edge,
880 &lineStart,
881 &lineEnd,
882 _self->ob_itself);
883 _res = Py_BuildValue("ll",
884 lineStart,
885 lineEnd);
886 return _res;
887}
888
Jack Jansen2369a981998-02-20 15:57:30 +0000889static PyObject *wasteObj_WEFindParagraph(_self, _args)
890 wasteObject *_self;
891 PyObject *_args;
892{
893 PyObject *_res = NULL;
894 SInt32 offset;
895 WEEdge edge;
896 SInt32 paragraphStart;
897 SInt32 paragraphEnd;
898 if (!PyArg_ParseTuple(_args, "lb",
899 &offset,
900 &edge))
901 return NULL;
902 WEFindParagraph(offset,
903 edge,
904 &paragraphStart,
905 &paragraphEnd,
906 _self->ob_itself);
907 _res = Py_BuildValue("ll",
908 paragraphStart,
909 paragraphEnd);
910 return _res;
911}
912
Jack Jansen90ecdf41996-04-16 14:29:15 +0000913static PyObject *wasteObj_WECopyRange(_self, _args)
914 wasteObject *_self;
915 PyObject *_args;
916{
917 PyObject *_res = NULL;
918 OSErr _err;
Jack Jansen2268af51996-08-06 16:04:22 +0000919 SInt32 rangeStart;
920 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +0000921 Handle hText;
922 StScrpHandle hStyles;
923 WESoupHandle hSoup;
924 if (!PyArg_ParseTuple(_args, "llO&O&O&",
925 &rangeStart,
926 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000927 OptResObj_Convert, &hText,
928 OptResObj_Convert, &hStyles,
929 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000930 return NULL;
931 _err = WECopyRange(rangeStart,
932 rangeEnd,
933 hText,
934 hStyles,
935 hSoup,
936 _self->ob_itself);
937 if (_err != noErr) return PyMac_Error(_err);
938 Py_INCREF(Py_None);
939 _res = Py_None;
940 return _res;
941}
942
943static PyObject *wasteObj_WEGetAlignment(_self, _args)
944 wasteObject *_self;
945 PyObject *_args;
946{
947 PyObject *_res = NULL;
948 WEAlignment _rv;
949 if (!PyArg_ParseTuple(_args, ""))
950 return NULL;
951 _rv = WEGetAlignment(_self->ob_itself);
952 _res = Py_BuildValue("b",
953 _rv);
954 return _res;
955}
956
957static PyObject *wasteObj_WESetAlignment(_self, _args)
958 wasteObject *_self;
959 PyObject *_args;
960{
961 PyObject *_res = NULL;
962 WEAlignment alignment;
963 if (!PyArg_ParseTuple(_args, "b",
964 &alignment))
965 return NULL;
966 WESetAlignment(alignment,
967 _self->ob_itself);
968 Py_INCREF(Py_None);
969 _res = Py_None;
970 return _res;
971}
972
Jack Jansen2369a981998-02-20 15:57:30 +0000973static PyObject *wasteObj_WEGetDirection(_self, _args)
974 wasteObject *_self;
975 PyObject *_args;
976{
977 PyObject *_res = NULL;
978 WEDirection _rv;
979 if (!PyArg_ParseTuple(_args, ""))
980 return NULL;
981 _rv = WEGetDirection(_self->ob_itself);
982 _res = Py_BuildValue("h",
983 _rv);
984 return _res;
985}
986
987static PyObject *wasteObj_WESetDirection(_self, _args)
988 wasteObject *_self;
989 PyObject *_args;
990{
991 PyObject *_res = NULL;
992 WEDirection direction;
993 if (!PyArg_ParseTuple(_args, "h",
994 &direction))
995 return NULL;
996 WESetDirection(direction,
997 _self->ob_itself);
998 Py_INCREF(Py_None);
999 _res = Py_None;
1000 return _res;
1001}
1002
Jack Jansen90ecdf41996-04-16 14:29:15 +00001003static PyObject *wasteObj_WECalText(_self, _args)
1004 wasteObject *_self;
1005 PyObject *_args;
1006{
1007 PyObject *_res = NULL;
1008 OSErr _err;
1009 if (!PyArg_ParseTuple(_args, ""))
1010 return NULL;
1011 _err = WECalText(_self->ob_itself);
1012 if (_err != noErr) return PyMac_Error(_err);
1013 Py_INCREF(Py_None);
1014 _res = Py_None;
1015 return _res;
1016}
1017
1018static PyObject *wasteObj_WEUpdate(_self, _args)
1019 wasteObject *_self;
1020 PyObject *_args;
1021{
1022 PyObject *_res = NULL;
1023 RgnHandle updateRgn;
1024 if (!PyArg_ParseTuple(_args, "O&",
1025 ResObj_Convert, &updateRgn))
1026 return NULL;
1027 WEUpdate(updateRgn,
1028 _self->ob_itself);
1029 Py_INCREF(Py_None);
1030 _res = Py_None;
1031 return _res;
1032}
1033
1034static PyObject *wasteObj_WEScroll(_self, _args)
1035 wasteObject *_self;
1036 PyObject *_args;
1037{
1038 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001039 SInt32 hOffset;
1040 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001041 if (!PyArg_ParseTuple(_args, "ll",
1042 &hOffset,
1043 &vOffset))
1044 return NULL;
1045 WEScroll(hOffset,
1046 vOffset,
1047 _self->ob_itself);
1048 Py_INCREF(Py_None);
1049 _res = Py_None;
1050 return _res;
1051}
1052
1053static PyObject *wasteObj_WESelView(_self, _args)
1054 wasteObject *_self;
1055 PyObject *_args;
1056{
1057 PyObject *_res = NULL;
1058 if (!PyArg_ParseTuple(_args, ""))
1059 return NULL;
1060 WESelView(_self->ob_itself);
1061 Py_INCREF(Py_None);
1062 _res = Py_None;
1063 return _res;
1064}
1065
1066static PyObject *wasteObj_WEActivate(_self, _args)
1067 wasteObject *_self;
1068 PyObject *_args;
1069{
1070 PyObject *_res = NULL;
1071 if (!PyArg_ParseTuple(_args, ""))
1072 return NULL;
1073 WEActivate(_self->ob_itself);
1074 Py_INCREF(Py_None);
1075 _res = Py_None;
1076 return _res;
1077}
1078
1079static PyObject *wasteObj_WEDeactivate(_self, _args)
1080 wasteObject *_self;
1081 PyObject *_args;
1082{
1083 PyObject *_res = NULL;
1084 if (!PyArg_ParseTuple(_args, ""))
1085 return NULL;
1086 WEDeactivate(_self->ob_itself);
1087 Py_INCREF(Py_None);
1088 _res = Py_None;
1089 return _res;
1090}
1091
1092static PyObject *wasteObj_WEKey(_self, _args)
1093 wasteObject *_self;
1094 PyObject *_args;
1095{
1096 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001097 SInt16 key;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001098 EventModifiers modifiers;
1099 if (!PyArg_ParseTuple(_args, "hh",
1100 &key,
1101 &modifiers))
1102 return NULL;
1103 WEKey(key,
1104 modifiers,
1105 _self->ob_itself);
1106 Py_INCREF(Py_None);
1107 _res = Py_None;
1108 return _res;
1109}
1110
1111static PyObject *wasteObj_WEClick(_self, _args)
1112 wasteObject *_self;
1113 PyObject *_args;
1114{
1115 PyObject *_res = NULL;
1116 Point hitPt;
1117 EventModifiers modifiers;
Jack Jansen2268af51996-08-06 16:04:22 +00001118 UInt32 clickTime;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001119 if (!PyArg_ParseTuple(_args, "O&hl",
1120 PyMac_GetPoint, &hitPt,
1121 &modifiers,
1122 &clickTime))
1123 return NULL;
1124 WEClick(hitPt,
1125 modifiers,
1126 clickTime,
1127 _self->ob_itself);
1128 Py_INCREF(Py_None);
1129 _res = Py_None;
1130 return _res;
1131}
1132
1133static PyObject *wasteObj_WEAdjustCursor(_self, _args)
1134 wasteObject *_self;
1135 PyObject *_args;
1136{
1137 PyObject *_res = NULL;
1138 Boolean _rv;
1139 Point mouseLoc;
1140 RgnHandle mouseRgn;
1141 if (!PyArg_ParseTuple(_args, "O&O&",
1142 PyMac_GetPoint, &mouseLoc,
1143 ResObj_Convert, &mouseRgn))
1144 return NULL;
1145 _rv = WEAdjustCursor(mouseLoc,
1146 mouseRgn,
1147 _self->ob_itself);
1148 _res = Py_BuildValue("b",
1149 _rv);
1150 return _res;
1151}
1152
1153static PyObject *wasteObj_WEIdle(_self, _args)
1154 wasteObject *_self;
1155 PyObject *_args;
1156{
1157 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001158 UInt32 maxSleep;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001159 if (!PyArg_ParseTuple(_args, ""))
1160 return NULL;
1161 WEIdle(&maxSleep,
1162 _self->ob_itself);
1163 _res = Py_BuildValue("l",
1164 maxSleep);
1165 return _res;
1166}
1167
1168static PyObject *wasteObj_WEInsert(_self, _args)
1169 wasteObject *_self;
1170 PyObject *_args;
1171{
1172 PyObject *_res = NULL;
1173 OSErr _err;
1174 char *pText__in__;
1175 long pText__len__;
1176 int pText__in_len__;
1177 StScrpHandle hStyles;
1178 WESoupHandle hSoup;
1179 if (!PyArg_ParseTuple(_args, "s#O&O&",
1180 &pText__in__, &pText__in_len__,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001181 OptResObj_Convert, &hStyles,
1182 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +00001183 return NULL;
1184 pText__len__ = pText__in_len__;
1185 _err = WEInsert(pText__in__, pText__len__,
1186 hStyles,
1187 hSoup,
1188 _self->ob_itself);
1189 if (_err != noErr) return PyMac_Error(_err);
1190 Py_INCREF(Py_None);
1191 _res = Py_None;
1192 pText__error__: ;
1193 return _res;
1194}
1195
1196static PyObject *wasteObj_WEDelete(_self, _args)
1197 wasteObject *_self;
1198 PyObject *_args;
1199{
1200 PyObject *_res = NULL;
1201 OSErr _err;
1202 if (!PyArg_ParseTuple(_args, ""))
1203 return NULL;
1204 _err = WEDelete(_self->ob_itself);
1205 if (_err != noErr) return PyMac_Error(_err);
1206 Py_INCREF(Py_None);
1207 _res = Py_None;
1208 return _res;
1209}
1210
1211static PyObject *wasteObj_WESetStyle(_self, _args)
1212 wasteObject *_self;
1213 PyObject *_args;
1214{
1215 PyObject *_res = NULL;
1216 OSErr _err;
1217 WEStyleMode mode;
1218 TextStyle ts;
1219 if (!PyArg_ParseTuple(_args, "hO&",
1220 &mode,
1221 TextStyle_Convert, &ts))
1222 return NULL;
1223 _err = WESetStyle(mode,
1224 &ts,
1225 _self->ob_itself);
1226 if (_err != noErr) return PyMac_Error(_err);
1227 Py_INCREF(Py_None);
1228 _res = Py_None;
1229 return _res;
1230}
1231
1232static PyObject *wasteObj_WEUseStyleScrap(_self, _args)
1233 wasteObject *_self;
1234 PyObject *_args;
1235{
1236 PyObject *_res = NULL;
1237 OSErr _err;
1238 StScrpHandle hStyles;
1239 if (!PyArg_ParseTuple(_args, "O&",
1240 ResObj_Convert, &hStyles))
1241 return NULL;
1242 _err = WEUseStyleScrap(hStyles,
1243 _self->ob_itself);
1244 if (_err != noErr) return PyMac_Error(_err);
1245 Py_INCREF(Py_None);
1246 _res = Py_None;
1247 return _res;
1248}
1249
1250static PyObject *wasteObj_WEUseText(_self, _args)
1251 wasteObject *_self;
1252 PyObject *_args;
1253{
1254 PyObject *_res = NULL;
1255 OSErr _err;
1256 Handle hText;
1257 if (!PyArg_ParseTuple(_args, "O&",
1258 ResObj_Convert, &hText))
1259 return NULL;
1260 _err = WEUseText(hText,
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
1268static PyObject *wasteObj_WEUndo(_self, _args)
1269 wasteObject *_self;
1270 PyObject *_args;
1271{
1272 PyObject *_res = NULL;
1273 OSErr _err;
1274 if (!PyArg_ParseTuple(_args, ""))
1275 return NULL;
1276 _err = WEUndo(_self->ob_itself);
1277 if (_err != noErr) return PyMac_Error(_err);
1278 Py_INCREF(Py_None);
1279 _res = Py_None;
1280 return _res;
1281}
1282
1283static PyObject *wasteObj_WEClearUndo(_self, _args)
1284 wasteObject *_self;
1285 PyObject *_args;
1286{
1287 PyObject *_res = NULL;
1288 if (!PyArg_ParseTuple(_args, ""))
1289 return NULL;
1290 WEClearUndo(_self->ob_itself);
1291 Py_INCREF(Py_None);
1292 _res = Py_None;
1293 return _res;
1294}
1295
1296static PyObject *wasteObj_WEGetUndoInfo(_self, _args)
1297 wasteObject *_self;
1298 PyObject *_args;
1299{
1300 PyObject *_res = NULL;
1301 WEActionKind _rv;
1302 Boolean redoFlag;
1303 if (!PyArg_ParseTuple(_args, ""))
1304 return NULL;
1305 _rv = WEGetUndoInfo(&redoFlag,
1306 _self->ob_itself);
1307 _res = Py_BuildValue("hb",
1308 _rv,
1309 redoFlag);
1310 return _res;
1311}
1312
1313static PyObject *wasteObj_WEIsTyping(_self, _args)
1314 wasteObject *_self;
1315 PyObject *_args;
1316{
1317 PyObject *_res = NULL;
1318 Boolean _rv;
1319 if (!PyArg_ParseTuple(_args, ""))
1320 return NULL;
1321 _rv = WEIsTyping(_self->ob_itself);
1322 _res = Py_BuildValue("b",
1323 _rv);
1324 return _res;
1325}
1326
Jack Jansen2369a981998-02-20 15:57:30 +00001327static PyObject *wasteObj_WEBeginAction(_self, _args)
1328 wasteObject *_self;
1329 PyObject *_args;
1330{
1331 PyObject *_res = NULL;
1332 OSErr _err;
1333 if (!PyArg_ParseTuple(_args, ""))
1334 return NULL;
1335 _err = WEBeginAction(_self->ob_itself);
1336 if (_err != noErr) return PyMac_Error(_err);
1337 Py_INCREF(Py_None);
1338 _res = Py_None;
1339 return _res;
1340}
1341
1342static PyObject *wasteObj_WEEndAction(_self, _args)
1343 wasteObject *_self;
1344 PyObject *_args;
1345{
1346 PyObject *_res = NULL;
1347 OSErr _err;
1348 WEActionKind actionKind;
1349 if (!PyArg_ParseTuple(_args, "h",
1350 &actionKind))
1351 return NULL;
1352 _err = WEEndAction(actionKind,
1353 _self->ob_itself);
1354 if (_err != noErr) return PyMac_Error(_err);
1355 Py_INCREF(Py_None);
1356 _res = Py_None;
1357 return _res;
1358}
1359
Jack Jansen90ecdf41996-04-16 14:29:15 +00001360static PyObject *wasteObj_WEGetModCount(_self, _args)
1361 wasteObject *_self;
1362 PyObject *_args;
1363{
1364 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001365 UInt32 _rv;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001366 if (!PyArg_ParseTuple(_args, ""))
1367 return NULL;
1368 _rv = WEGetModCount(_self->ob_itself);
1369 _res = Py_BuildValue("l",
1370 _rv);
1371 return _res;
1372}
1373
1374static PyObject *wasteObj_WEResetModCount(_self, _args)
1375 wasteObject *_self;
1376 PyObject *_args;
1377{
1378 PyObject *_res = NULL;
1379 if (!PyArg_ParseTuple(_args, ""))
1380 return NULL;
1381 WEResetModCount(_self->ob_itself);
1382 Py_INCREF(Py_None);
1383 _res = Py_None;
1384 return _res;
1385}
1386
1387static PyObject *wasteObj_WEInsertObject(_self, _args)
1388 wasteObject *_self;
1389 PyObject *_args;
1390{
1391 PyObject *_res = NULL;
1392 OSErr _err;
1393 FlavorType objectType;
1394 Handle objectDataHandle;
1395 Point objectSize;
1396 if (!PyArg_ParseTuple(_args, "O&O&O&",
1397 PyMac_GetOSType, &objectType,
1398 ResObj_Convert, &objectDataHandle,
1399 PyMac_GetPoint, &objectSize))
1400 return NULL;
1401 _err = WEInsertObject(objectType,
1402 objectDataHandle,
1403 objectSize,
1404 _self->ob_itself);
1405 if (_err != noErr) return PyMac_Error(_err);
1406 Py_INCREF(Py_None);
1407 _res = Py_None;
1408 return _res;
1409}
1410
1411static PyObject *wasteObj_WEGetSelectedObject(_self, _args)
1412 wasteObject *_self;
1413 PyObject *_args;
1414{
1415 PyObject *_res = NULL;
1416 OSErr _err;
1417 WEObjectReference obj;
1418 if (!PyArg_ParseTuple(_args, ""))
1419 return NULL;
1420 _err = WEGetSelectedObject(&obj,
1421 _self->ob_itself);
1422 if (_err != noErr) return PyMac_Error(_err);
1423 _res = Py_BuildValue("O&",
1424 WEOObj_New, obj);
1425 return _res;
1426}
1427
1428static PyObject *wasteObj_WEFindNextObject(_self, _args)
1429 wasteObject *_self;
1430 PyObject *_args;
1431{
1432 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001433 SInt32 _rv;
1434 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001435 WEObjectReference obj;
1436 if (!PyArg_ParseTuple(_args, "l",
1437 &offset))
1438 return NULL;
1439 _rv = WEFindNextObject(offset,
1440 &obj,
1441 _self->ob_itself);
1442 _res = Py_BuildValue("lO&",
1443 _rv,
1444 WEOObj_New, obj);
1445 return _res;
1446}
1447
1448static PyObject *wasteObj_WEUseSoup(_self, _args)
1449 wasteObject *_self;
1450 PyObject *_args;
1451{
1452 PyObject *_res = NULL;
1453 OSErr _err;
1454 WESoupHandle hSoup;
1455 if (!PyArg_ParseTuple(_args, "O&",
1456 ResObj_Convert, &hSoup))
1457 return NULL;
1458 _err = WEUseSoup(hSoup,
1459 _self->ob_itself);
1460 if (_err != noErr) return PyMac_Error(_err);
1461 Py_INCREF(Py_None);
1462 _res = Py_None;
1463 return _res;
1464}
1465
1466static PyObject *wasteObj_WECut(_self, _args)
1467 wasteObject *_self;
1468 PyObject *_args;
1469{
1470 PyObject *_res = NULL;
1471 OSErr _err;
1472 if (!PyArg_ParseTuple(_args, ""))
1473 return NULL;
1474 _err = WECut(_self->ob_itself);
1475 if (_err != noErr) return PyMac_Error(_err);
1476 Py_INCREF(Py_None);
1477 _res = Py_None;
1478 return _res;
1479}
1480
1481static PyObject *wasteObj_WECopy(_self, _args)
1482 wasteObject *_self;
1483 PyObject *_args;
1484{
1485 PyObject *_res = NULL;
1486 OSErr _err;
1487 if (!PyArg_ParseTuple(_args, ""))
1488 return NULL;
1489 _err = WECopy(_self->ob_itself);
1490 if (_err != noErr) return PyMac_Error(_err);
1491 Py_INCREF(Py_None);
1492 _res = Py_None;
1493 return _res;
1494}
1495
1496static PyObject *wasteObj_WEPaste(_self, _args)
1497 wasteObject *_self;
1498 PyObject *_args;
1499{
1500 PyObject *_res = NULL;
1501 OSErr _err;
1502 if (!PyArg_ParseTuple(_args, ""))
1503 return NULL;
1504 _err = WEPaste(_self->ob_itself);
1505 if (_err != noErr) return PyMac_Error(_err);
1506 Py_INCREF(Py_None);
1507 _res = Py_None;
1508 return _res;
1509}
1510
1511static PyObject *wasteObj_WECanPaste(_self, _args)
1512 wasteObject *_self;
1513 PyObject *_args;
1514{
1515 PyObject *_res = NULL;
1516 Boolean _rv;
1517 if (!PyArg_ParseTuple(_args, ""))
1518 return NULL;
1519 _rv = WECanPaste(_self->ob_itself);
1520 _res = Py_BuildValue("b",
1521 _rv);
1522 return _res;
1523}
1524
1525static PyObject *wasteObj_WEGetHiliteRgn(_self, _args)
1526 wasteObject *_self;
1527 PyObject *_args;
1528{
1529 PyObject *_res = NULL;
1530 RgnHandle _rv;
Jack Jansen2268af51996-08-06 16:04:22 +00001531 SInt32 rangeStart;
1532 SInt32 rangeEnd;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001533 if (!PyArg_ParseTuple(_args, "ll",
1534 &rangeStart,
1535 &rangeEnd))
1536 return NULL;
1537 _rv = WEGetHiliteRgn(rangeStart,
1538 rangeEnd,
1539 _self->ob_itself);
1540 _res = Py_BuildValue("O&",
1541 ResObj_New, _rv);
1542 return _res;
1543}
1544
1545static PyObject *wasteObj_WECharByte(_self, _args)
1546 wasteObject *_self;
1547 PyObject *_args;
1548{
1549 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001550 SInt16 _rv;
1551 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001552 if (!PyArg_ParseTuple(_args, "l",
1553 &offset))
1554 return NULL;
1555 _rv = WECharByte(offset,
1556 _self->ob_itself);
1557 _res = Py_BuildValue("h",
1558 _rv);
1559 return _res;
1560}
1561
1562static PyObject *wasteObj_WECharType(_self, _args)
1563 wasteObject *_self;
1564 PyObject *_args;
1565{
1566 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001567 SInt16 _rv;
1568 SInt32 offset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001569 if (!PyArg_ParseTuple(_args, "l",
1570 &offset))
1571 return NULL;
1572 _rv = WECharType(offset,
1573 _self->ob_itself);
1574 _res = Py_BuildValue("h",
1575 _rv);
1576 return _res;
1577}
1578
1579static PyObject *wasteObj_WEStopInlineSession(_self, _args)
1580 wasteObject *_self;
1581 PyObject *_args;
1582{
1583 PyObject *_res = NULL;
1584 if (!PyArg_ParseTuple(_args, ""))
1585 return NULL;
1586 WEStopInlineSession(_self->ob_itself);
1587 Py_INCREF(Py_None);
1588 _res = Py_None;
1589 return _res;
1590}
1591
1592static PyObject *wasteObj_WEFeatureFlag(_self, _args)
1593 wasteObject *_self;
1594 PyObject *_args;
1595{
1596 PyObject *_res = NULL;
Jack Jansen2268af51996-08-06 16:04:22 +00001597 SInt16 _rv;
1598 SInt16 feature;
1599 SInt16 action;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001600 if (!PyArg_ParseTuple(_args, "hh",
1601 &feature,
1602 &action))
1603 return NULL;
1604 _rv = WEFeatureFlag(feature,
1605 action,
1606 _self->ob_itself);
1607 _res = Py_BuildValue("h",
1608 _rv);
1609 return _res;
1610}
1611
Jack Jansen2369a981998-02-20 15:57:30 +00001612static PyObject *wasteObj_WEGetUserInfo(_self, _args)
1613 wasteObject *_self;
1614 PyObject *_args;
1615{
1616 PyObject *_res = NULL;
1617 OSErr _err;
1618 WESelector tag;
1619 SInt32 userInfo;
1620 if (!PyArg_ParseTuple(_args, "O&",
1621 PyMac_GetOSType, &tag))
1622 return NULL;
1623 _err = WEGetUserInfo(tag,
1624 &userInfo,
1625 _self->ob_itself);
1626 if (_err != noErr) return PyMac_Error(_err);
1627 _res = Py_BuildValue("l",
1628 userInfo);
1629 return _res;
1630}
1631
1632static PyObject *wasteObj_WESetUserInfo(_self, _args)
1633 wasteObject *_self;
1634 PyObject *_args;
1635{
1636 PyObject *_res = NULL;
1637 OSErr _err;
1638 WESelector tag;
1639 SInt32 userInfo;
1640 if (!PyArg_ParseTuple(_args, "O&l",
1641 PyMac_GetOSType, &tag,
1642 &userInfo))
1643 return NULL;
1644 _err = WESetUserInfo(tag,
1645 userInfo,
1646 _self->ob_itself);
1647 if (_err != noErr) return PyMac_Error(_err);
1648 Py_INCREF(Py_None);
1649 _res = Py_None;
1650 return _res;
1651}
1652
Jack Jansen176f3a91996-10-23 15:43:46 +00001653static PyObject *wasteObj_WEInstallTabHooks(_self, _args)
1654 wasteObject *_self;
1655 PyObject *_args;
1656{
1657 PyObject *_res = NULL;
1658 OSErr _err;
1659 if (!PyArg_ParseTuple(_args, ""))
1660 return NULL;
1661 _err = WEInstallTabHooks(_self->ob_itself);
1662 if (_err != noErr) return PyMac_Error(_err);
1663 Py_INCREF(Py_None);
1664 _res = Py_None;
1665 return _res;
1666}
1667
1668static PyObject *wasteObj_WERemoveTabHooks(_self, _args)
1669 wasteObject *_self;
1670 PyObject *_args;
1671{
1672 PyObject *_res = NULL;
1673 OSErr _err;
1674 if (!PyArg_ParseTuple(_args, ""))
1675 return NULL;
1676 _err = WERemoveTabHooks(_self->ob_itself);
1677 if (_err != noErr) return PyMac_Error(_err);
1678 Py_INCREF(Py_None);
1679 _res = Py_None;
1680 return _res;
1681}
1682
1683static PyObject *wasteObj_WEIsTabHooks(_self, _args)
1684 wasteObject *_self;
1685 PyObject *_args;
1686{
1687 PyObject *_res = NULL;
1688 Boolean _rv;
1689 if (!PyArg_ParseTuple(_args, ""))
1690 return NULL;
1691 _rv = WEIsTabHooks(_self->ob_itself);
1692 _res = Py_BuildValue("b",
1693 _rv);
1694 return _res;
1695}
1696
Jack Jansena4f03091998-03-02 16:56:18 +00001697static PyObject *wasteObj_WEGetTabSize(_self, _args)
1698 wasteObject *_self;
1699 PyObject *_args;
1700{
1701 PyObject *_res = NULL;
1702 SInt16 _rv;
1703 if (!PyArg_ParseTuple(_args, ""))
1704 return NULL;
1705 _rv = WEGetTabSize(_self->ob_itself);
1706 _res = Py_BuildValue("h",
1707 _rv);
1708 return _res;
1709}
1710
1711static PyObject *wasteObj_WESetTabSize(_self, _args)
1712 wasteObject *_self;
1713 PyObject *_args;
1714{
1715 PyObject *_res = NULL;
1716 OSErr _err;
1717 SInt16 tabWidth;
1718 if (!PyArg_ParseTuple(_args, "h",
1719 &tabWidth))
1720 return NULL;
1721 _err = WESetTabSize(tabWidth,
1722 _self->ob_itself);
1723 if (_err != noErr) return PyMac_Error(_err);
1724 Py_INCREF(Py_None);
1725 _res = Py_None;
1726 return _res;
1727}
1728
Jack Jansen90ecdf41996-04-16 14:29:15 +00001729static PyMethodDef wasteObj_methods[] = {
1730 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1731 "() -> (Handle _rv)"},
1732 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001733 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001734 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001735 "() -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001736 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001737 "(SInt32 startLine, SInt32 endLine) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001738 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001739 "() -> (SInt32 selStart, SInt32 selEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001740 {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1,
1741 "() -> (LongRect destRect)"},
1742 {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1,
1743 "() -> (LongRect viewRect)"},
1744 {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1,
1745 "() -> (Boolean _rv)"},
1746 {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001747 "(SInt32 offset) -> (SInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001748 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
Jack Jansen2369a981998-02-20 15:57:30 +00001749 "(SInt32 lineIndex) -> (SInt32 lineStart, SInt32 lineEnd)"},
1750 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
1751 "() -> (SInt32 _rv)"},
1752 {"WEOffsetToRun", (PyCFunction)wasteObj_WEOffsetToRun, 1,
1753 "(SInt32 offset) -> (SInt32 _rv)"},
1754 {"WEGetRunRange", (PyCFunction)wasteObj_WEGetRunRange, 1,
1755 "(SInt32 runIndex) -> (SInt32 runStart, SInt32 runEnd)"},
1756 {"WECountRuns", (PyCFunction)wasteObj_WECountRuns, 1,
1757 "() -> (SInt32 _rv)"},
Jack Jansen2268af51996-08-06 16:04:22 +00001758 {"WEGetClickCount", (PyCFunction)wasteObj_WEGetClickCount, 1,
1759 "() -> (UInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001760 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001761 "(SInt32 selStart, SInt32 selEnd) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001762 {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1,
1763 "(LongRect destRect) -> None"},
1764 {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1,
1765 "(LongRect viewRect) -> None"},
1766 {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001767 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001768 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001769 "(SInt32 offset) -> (WERunInfo runInfo)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001770 {"WEGetRunDirection", (PyCFunction)wasteObj_WEGetRunDirection, 1,
1771 "(SInt32 offset) -> (Boolean _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001772 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001773 "(LongPt thePoint) -> (SInt32 _rv, WEEdge edge)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001774 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001775 "(SInt32 offset, SInt16 direction) -> (LongPt thePoint, SInt16 lineHeight)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001776 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001777 "(SInt32 offset, WEEdge edge) -> (SInt32 wordStart, SInt32 wordEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001778 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001779 "(SInt32 offset, WEEdge edge) -> (SInt32 lineStart, SInt32 lineEnd)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001780 {"WEFindParagraph", (PyCFunction)wasteObj_WEFindParagraph, 1,
1781 "(SInt32 offset, WEEdge edge) -> (SInt32 paragraphStart, SInt32 paragraphEnd)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001782 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001783 "(SInt32 rangeStart, SInt32 rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001784 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1785 "() -> (WEAlignment _rv)"},
1786 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1787 "(WEAlignment alignment) -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00001788 {"WEGetDirection", (PyCFunction)wasteObj_WEGetDirection, 1,
1789 "() -> (WEDirection _rv)"},
1790 {"WESetDirection", (PyCFunction)wasteObj_WESetDirection, 1,
1791 "(WEDirection direction) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001792 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1793 "() -> None"},
1794 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1795 "(RgnHandle updateRgn) -> None"},
1796 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001797 "(SInt32 hOffset, SInt32 vOffset) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001798 {"WESelView", (PyCFunction)wasteObj_WESelView, 1,
1799 "() -> None"},
1800 {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1,
1801 "() -> None"},
1802 {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1,
1803 "() -> None"},
1804 {"WEKey", (PyCFunction)wasteObj_WEKey, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001805 "(SInt16 key, EventModifiers modifiers) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001806 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001807 "(Point hitPt, EventModifiers modifiers, UInt32 clickTime) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001808 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1809 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1810 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001811 "() -> (UInt32 maxSleep)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001812 {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1,
1813 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1814 {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1,
1815 "() -> None"},
1816 {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1,
1817 "(WEStyleMode mode, TextStyle ts) -> None"},
1818 {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1,
1819 "(StScrpHandle hStyles) -> None"},
1820 {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1,
1821 "(Handle hText) -> None"},
1822 {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1,
1823 "() -> None"},
1824 {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1,
1825 "() -> None"},
1826 {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1,
1827 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1828 {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1,
1829 "() -> (Boolean _rv)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001830 {"WEBeginAction", (PyCFunction)wasteObj_WEBeginAction, 1,
1831 "() -> None"},
1832 {"WEEndAction", (PyCFunction)wasteObj_WEEndAction, 1,
1833 "(WEActionKind actionKind) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001834 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001835 "() -> (UInt32 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001836 {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1,
1837 "() -> None"},
1838 {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1,
1839 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1840 {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1,
1841 "() -> (WEObjectReference obj)"},
1842 {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001843 "(SInt32 offset) -> (SInt32 _rv, WEObjectReference obj)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001844 {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1,
1845 "(WESoupHandle hSoup) -> None"},
1846 {"WECut", (PyCFunction)wasteObj_WECut, 1,
1847 "() -> None"},
1848 {"WECopy", (PyCFunction)wasteObj_WECopy, 1,
1849 "() -> None"},
1850 {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1,
1851 "() -> None"},
1852 {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1,
1853 "() -> (Boolean _rv)"},
1854 {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001855 "(SInt32 rangeStart, SInt32 rangeEnd) -> (RgnHandle _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001856 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001857 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001858 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001859 "(SInt32 offset) -> (SInt16 _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001860 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1861 "() -> None"},
1862 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00001863 "(SInt16 feature, SInt16 action) -> (SInt16 _rv)"},
Jack Jansen2369a981998-02-20 15:57:30 +00001864 {"WEGetUserInfo", (PyCFunction)wasteObj_WEGetUserInfo, 1,
1865 "(WESelector tag) -> (SInt32 userInfo)"},
1866 {"WESetUserInfo", (PyCFunction)wasteObj_WESetUserInfo, 1,
1867 "(WESelector tag, SInt32 userInfo) -> None"},
Jack Jansen176f3a91996-10-23 15:43:46 +00001868 {"WEInstallTabHooks", (PyCFunction)wasteObj_WEInstallTabHooks, 1,
1869 "() -> None"},
1870 {"WERemoveTabHooks", (PyCFunction)wasteObj_WERemoveTabHooks, 1,
1871 "() -> None"},
1872 {"WEIsTabHooks", (PyCFunction)wasteObj_WEIsTabHooks, 1,
1873 "() -> (Boolean _rv)"},
Jack Jansena4f03091998-03-02 16:56:18 +00001874 {"WEGetTabSize", (PyCFunction)wasteObj_WEGetTabSize, 1,
1875 "() -> (SInt16 _rv)"},
1876 {"WESetTabSize", (PyCFunction)wasteObj_WESetTabSize, 1,
1877 "(SInt16 tabWidth) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001878 {NULL, NULL, 0}
1879};
1880
1881PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1882
1883static PyObject *wasteObj_getattr(self, name)
1884 wasteObject *self;
1885 char *name;
1886{
1887 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1888}
1889
1890#define wasteObj_setattr NULL
1891
1892PyTypeObject waste_Type = {
1893 PyObject_HEAD_INIT(&PyType_Type)
1894 0, /*ob_size*/
1895 "waste", /*tp_name*/
1896 sizeof(wasteObject), /*tp_basicsize*/
1897 0, /*tp_itemsize*/
1898 /* methods */
1899 (destructor) wasteObj_dealloc, /*tp_dealloc*/
1900 0, /*tp_print*/
1901 (getattrfunc) wasteObj_getattr, /*tp_getattr*/
1902 (setattrfunc) wasteObj_setattr, /*tp_setattr*/
1903};
1904
1905/* --------------------- End object type waste ---------------------- */
1906
1907
1908static PyObject *waste_WENew(_self, _args)
1909 PyObject *_self;
1910 PyObject *_args;
1911{
1912 PyObject *_res = NULL;
1913 OSErr _err;
1914 LongRect destRect;
1915 LongRect viewRect;
Jack Jansen2268af51996-08-06 16:04:22 +00001916 UInt32 flags;
Jack Jansen90ecdf41996-04-16 14:29:15 +00001917 WEReference we;
1918 if (!PyArg_ParseTuple(_args, "O&O&l",
1919 LongRect_Convert, &destRect,
1920 LongRect_Convert, &viewRect,
1921 &flags))
1922 return NULL;
1923 _err = WENew(&destRect,
1924 &viewRect,
1925 flags,
1926 &we);
1927 if (_err != noErr) return PyMac_Error(_err);
1928 _res = Py_BuildValue("O&",
1929 wasteObj_New, we);
1930 return _res;
1931}
1932
Jack Jansen2369a981998-02-20 15:57:30 +00001933static PyObject *waste_WEUpdateStyleScrap(_self, _args)
1934 PyObject *_self;
1935 PyObject *_args;
1936{
1937 PyObject *_res = NULL;
1938 OSErr _err;
1939 StScrpHandle hStyles;
1940 WEFontTableHandle hFontTable;
1941 if (!PyArg_ParseTuple(_args, "O&O&",
1942 ResObj_Convert, &hStyles,
1943 ResObj_Convert, &hFontTable))
1944 return NULL;
1945 _err = WEUpdateStyleScrap(hStyles,
1946 hFontTable);
1947 if (_err != noErr) return PyMac_Error(_err);
1948 Py_INCREF(Py_None);
1949 _res = Py_None;
1950 return _res;
1951}
1952
Jack Jansen90ecdf41996-04-16 14:29:15 +00001953static PyObject *waste_WEInstallTSMHandlers(_self, _args)
1954 PyObject *_self;
1955 PyObject *_args;
1956{
1957 PyObject *_res = NULL;
1958 OSErr _err;
1959 if (!PyArg_ParseTuple(_args, ""))
1960 return NULL;
1961 _err = WEInstallTSMHandlers();
1962 if (_err != noErr) return PyMac_Error(_err);
1963 Py_INCREF(Py_None);
1964 _res = Py_None;
1965 return _res;
1966}
1967
1968static PyObject *waste_WERemoveTSMHandlers(_self, _args)
1969 PyObject *_self;
1970 PyObject *_args;
1971{
1972 PyObject *_res = NULL;
1973 OSErr _err;
1974 if (!PyArg_ParseTuple(_args, ""))
1975 return NULL;
1976 _err = WERemoveTSMHandlers();
1977 if (_err != noErr) return PyMac_Error(_err);
1978 Py_INCREF(Py_None);
1979 _res = Py_None;
1980 return _res;
1981}
1982
Jack Jansen2369a981998-02-20 15:57:30 +00001983static PyObject *waste_WEHandleTSMEvent(_self, _args)
1984 PyObject *_self;
1985 PyObject *_args;
1986{
1987 PyObject *_res = NULL;
1988 OSErr _err;
1989 AppleEvent ae;
1990 AppleEvent reply;
1991 if (!PyArg_ParseTuple(_args, "O&",
1992 AEDesc_Convert, &ae))
1993 return NULL;
1994 _err = WEHandleTSMEvent(&ae,
1995 &reply);
1996 if (_err != noErr) return PyMac_Error(_err);
1997 _res = Py_BuildValue("O&",
1998 AEDesc_New, &reply);
1999 return _res;
2000}
2001
Jack Jansen90ecdf41996-04-16 14:29:15 +00002002static PyObject *waste_WELongPointToPoint(_self, _args)
2003 PyObject *_self;
2004 PyObject *_args;
2005{
2006 PyObject *_res = NULL;
2007 LongPt lp;
2008 Point p;
2009 if (!PyArg_ParseTuple(_args, "O&",
2010 LongPt_Convert, &lp))
2011 return NULL;
2012 WELongPointToPoint(&lp,
2013 &p);
2014 _res = Py_BuildValue("O&",
2015 PyMac_BuildPoint, p);
2016 return _res;
2017}
2018
2019static PyObject *waste_WEPointToLongPoint(_self, _args)
2020 PyObject *_self;
2021 PyObject *_args;
2022{
2023 PyObject *_res = NULL;
2024 Point p;
2025 LongPt lp;
2026 if (!PyArg_ParseTuple(_args, "O&",
2027 PyMac_GetPoint, &p))
2028 return NULL;
2029 WEPointToLongPoint(p,
2030 &lp);
2031 _res = Py_BuildValue("O&",
2032 LongPt_New, &lp);
2033 return _res;
2034}
2035
2036static PyObject *waste_WESetLongRect(_self, _args)
2037 PyObject *_self;
2038 PyObject *_args;
2039{
2040 PyObject *_res = NULL;
2041 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00002042 SInt32 left;
2043 SInt32 top;
2044 SInt32 right;
2045 SInt32 bottom;
Jack Jansen90ecdf41996-04-16 14:29:15 +00002046 if (!PyArg_ParseTuple(_args, "llll",
2047 &left,
2048 &top,
2049 &right,
2050 &bottom))
2051 return NULL;
2052 WESetLongRect(&lr,
2053 left,
2054 top,
2055 right,
2056 bottom);
2057 _res = Py_BuildValue("O&",
2058 LongRect_New, &lr);
2059 return _res;
2060}
2061
2062static PyObject *waste_WELongRectToRect(_self, _args)
2063 PyObject *_self;
2064 PyObject *_args;
2065{
2066 PyObject *_res = NULL;
2067 LongRect lr;
2068 Rect r;
2069 if (!PyArg_ParseTuple(_args, "O&",
2070 LongRect_Convert, &lr))
2071 return NULL;
2072 WELongRectToRect(&lr,
2073 &r);
2074 _res = Py_BuildValue("O&",
2075 PyMac_BuildRect, &r);
2076 return _res;
2077}
2078
2079static PyObject *waste_WERectToLongRect(_self, _args)
2080 PyObject *_self;
2081 PyObject *_args;
2082{
2083 PyObject *_res = NULL;
2084 Rect r;
2085 LongRect lr;
2086 if (!PyArg_ParseTuple(_args, "O&",
2087 PyMac_GetRect, &r))
2088 return NULL;
2089 WERectToLongRect(&r,
2090 &lr);
2091 _res = Py_BuildValue("O&",
2092 LongRect_New, &lr);
2093 return _res;
2094}
2095
2096static PyObject *waste_WEOffsetLongRect(_self, _args)
2097 PyObject *_self;
2098 PyObject *_args;
2099{
2100 PyObject *_res = NULL;
2101 LongRect lr;
Jack Jansen2268af51996-08-06 16:04:22 +00002102 SInt32 hOffset;
2103 SInt32 vOffset;
Jack Jansen90ecdf41996-04-16 14:29:15 +00002104 if (!PyArg_ParseTuple(_args, "ll",
2105 &hOffset,
2106 &vOffset))
2107 return NULL;
2108 WEOffsetLongRect(&lr,
2109 hOffset,
2110 vOffset);
2111 _res = Py_BuildValue("O&",
2112 LongRect_New, &lr);
2113 return _res;
2114}
2115
2116static PyObject *waste_WELongPointInLongRect(_self, _args)
2117 PyObject *_self;
2118 PyObject *_args;
2119{
2120 PyObject *_res = NULL;
2121 Boolean _rv;
2122 LongPt lp;
2123 LongRect lr;
2124 if (!PyArg_ParseTuple(_args, "O&O&",
2125 LongPt_Convert, &lp,
2126 LongRect_Convert, &lr))
2127 return NULL;
2128 _rv = WELongPointInLongRect(&lp,
2129 &lr);
2130 _res = Py_BuildValue("b",
2131 _rv);
2132 return _res;
2133}
2134
Jack Jansen756522f1996-05-07 15:24:01 +00002135static PyObject *waste_STDObjectHandlers(_self, _args)
2136 PyObject *_self;
2137 PyObject *_args;
2138{
2139 PyObject *_res = NULL;
2140
2141 OSErr err;
2142 // install the sample object handlers for pictures and sounds
2143#define kTypePicture 'PICT'
2144#define kTypeSound 'snd '
2145
2146 if ( !PyArg_ParseTuple(_args, "") ) return NULL;
2147
2148 if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
2149 (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
2150 goto cleanup;
2151
2152 if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
2153 (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
2154 goto cleanup;
2155
2156 if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
2157 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
2158 goto cleanup;
2159
2160 if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
2161 (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
2162 goto cleanup;
2163
2164 if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
2165 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
2166 goto cleanup;
2167
2168 if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
2169 (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
2170 goto cleanup;
2171 Py_INCREF(Py_None);
2172 return Py_None;
2173
2174 cleanup:
2175 return PyMac_Error(err);
2176
2177}
2178
2179static PyObject *waste_WEInstallObjectHandler(_self, _args)
2180 PyObject *_self;
2181 PyObject *_args;
2182{
2183 PyObject *_res = NULL;
2184
2185 OSErr err;
2186 FlavorType objectType;
2187 WESelector selector;
2188 PyObject *py_handler;
2189 UniversalProcPtr handler;
2190 WEReference we = NULL;
2191 PyObject *key;
2192
2193
2194 if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
2195 PyMac_GetOSType, &objectType,
2196 PyMac_GetOSType, &selector,
2197 &py_handler,
Jack Jansen7df36061996-10-01 11:41:14 +00002198 WEOObj_Convert, &we) ) return NULL;
Jack Jansen756522f1996-05-07 15:24:01 +00002199
Jack Jansen25241d91996-05-20 11:30:45 +00002200 if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
2201 else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
2202 else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
2203 else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +00002204 else return PyMac_Error(weUndefinedSelectorErr);
2205
2206 if ((key = Py_BuildValue("O&O&",
2207 PyMac_BuildOSType, objectType,
2208 PyMac_BuildOSType, selector)) == NULL )
2209 return NULL;
2210
2211 PyDict_SetItem(callbackdict, key, py_handler);
2212
2213 err = WEInstallObjectHandler(objectType, selector, handler, we);
2214 if ( err ) return PyMac_Error(err);
2215 Py_INCREF(Py_None);
2216 return Py_None;
2217
2218}
2219
Jack Jansen90ecdf41996-04-16 14:29:15 +00002220static PyMethodDef waste_methods[] = {
2221 {"WENew", (PyCFunction)waste_WENew, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002222 "(LongRect destRect, LongRect viewRect, UInt32 flags) -> (WEReference we)"},
Jack Jansen2369a981998-02-20 15:57:30 +00002223 {"WEUpdateStyleScrap", (PyCFunction)waste_WEUpdateStyleScrap, 1,
2224 "(StScrpHandle hStyles, WEFontTableHandle hFontTable) -> None"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002225 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
2226 "() -> None"},
2227 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
2228 "() -> None"},
Jack Jansen2369a981998-02-20 15:57:30 +00002229 {"WEHandleTSMEvent", (PyCFunction)waste_WEHandleTSMEvent, 1,
2230 "(AppleEvent ae) -> (AppleEvent reply)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002231 {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1,
2232 "(LongPt lp) -> (Point p)"},
2233 {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1,
2234 "(Point p) -> (LongPt lp)"},
2235 {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002236 "(SInt32 left, SInt32 top, SInt32 right, SInt32 bottom) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002237 {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1,
2238 "(LongRect lr) -> (Rect r)"},
2239 {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1,
2240 "(Rect r) -> (LongRect lr)"},
2241 {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1,
Jack Jansen2268af51996-08-06 16:04:22 +00002242 "(SInt32 hOffset, SInt32 vOffset) -> (LongRect lr)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002243 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
2244 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +00002245 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
2246 NULL},
2247 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
2248 NULL},
Jack Jansen90ecdf41996-04-16 14:29:15 +00002249 {NULL, NULL, 0}
2250};
2251
2252
2253
Jack Jansen756522f1996-05-07 15:24:01 +00002254/* Return the object corresponding to the window, or NULL */
2255
2256PyObject *
2257ExistingwasteObj_New(w)
2258 WEReference w;
2259{
2260 PyObject *it = NULL;
2261
2262 if (w == NULL)
2263 it = NULL;
2264 else
2265 WEGetInfo(weRefCon, (void *)&it, w);
2266 if (it == NULL || ((wasteObject *)it)->ob_itself != w)
2267 it = Py_None;
2268 Py_INCREF(it);
2269 return it;
2270}
2271
Jack Jansen90ecdf41996-04-16 14:29:15 +00002272
2273void initwaste()
2274{
2275 PyObject *m;
2276 PyObject *d;
2277
2278
2279
2280
2281 m = Py_InitModule("waste", waste_methods);
2282 d = PyModule_GetDict(m);
2283 waste_Error = PyMac_GetOSErrException();
2284 if (waste_Error == NULL ||
2285 PyDict_SetItemString(d, "Error", waste_Error) != 0)
2286 Py_FatalError("can't initialize waste.Error");
Jack Jansena755e681997-09-20 17:40:22 +00002287 WEO_Type.ob_type = &PyType_Type;
2288 Py_INCREF(&WEO_Type);
2289 if (PyDict_SetItemString(d, "WEOType", (PyObject *)&WEO_Type) != 0)
2290 Py_FatalError("can't initialize WEOType");
2291 waste_Type.ob_type = &PyType_Type;
2292 Py_INCREF(&waste_Type);
2293 if (PyDict_SetItemString(d, "wasteType", (PyObject *)&waste_Type) != 0)
2294 Py_FatalError("can't initialize wasteType");
Jack Jansen756522f1996-05-07 15:24:01 +00002295
2296 callbackdict = PyDict_New();
2297 if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
2298 Py_FatalError("can't initialize Waste.callbackdict");
2299 upp_new_handler = NewWENewObjectProc(my_new_handler);
Jack Jansen25241d91996-05-20 11:30:45 +00002300 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
2301 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
2302 upp_click_handler = NewWEClickObjectProc(my_click_handler);
Jack Jansen756522f1996-05-07 15:24:01 +00002303
2304
Jack Jansen90ecdf41996-04-16 14:29:15 +00002305}
2306
2307/* ======================== End module waste ======================== */
2308