blob: 9c62d1c91e9c1ea41fa7a2a587f0943004ccf770 [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 Jansen756522f1996-05-07 15:24:01 +000046#include <WEObjectHandlers.h>
Jack Jansen90ecdf41996-04-16 14:29:15 +000047
48/* Exported by Qdmodule.c: */
49extern PyObject *QdRGB_New(RGBColor *);
50extern int QdRGB_Convert(PyObject *, RGBColor *);
51
52/* Forward declaration */
53staticforward PyObject *WEOObj_New(WEObjectReference);
Jack Jansen756522f1996-05-07 15:24:01 +000054staticforward PyObject *ExistingwasteObj_New(WEReference);
Jack Jansen90ecdf41996-04-16 14:29:15 +000055
56/*
57** Parse/generate TextStyle records
58*/
59static
60PyObject *TextStyle_New(itself)
61 TextStylePtr itself;
62{
63
64 return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New,
65 &itself->tsColor);
66}
67
68static
69TextStyle_Convert(v, p_itself)
70 PyObject *v;
71 TextStylePtr p_itself;
72{
73 long font, face, size;
74
75 if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) )
76 return 0;
77 p_itself->tsFont = (short)font;
78 p_itself->tsFace = (Style)face;
79 p_itself->tsSize = (short)size;
80 return 1;
81}
82
83/*
84** Parse/generate RunInfo records
85*/
86static
87PyObject *RunInfo_New(itself)
88 WERunInfo *itself;
89{
90
91 return Py_BuildValue("llhhO&O&", itself->runStart, itself->runEnd, itself->runHeight,
92 itself->runAscent, TextStyle_New, &itself->runStyle, WEOObj_New, itself->runObject);
93}
94
95/* Conversion of long points and rects */
96int
97LongRect_Convert(PyObject *v, LongRect *r)
98{
99 return PyArg_Parse(v, "(llll)", &r->left, &r->top, &r->right, &r->bottom);
100}
101
102PyObject *
103LongRect_New(LongRect *r)
104{
105 return Py_BuildValue("(llll)", r->left, r->top, r->right, r->bottom);
106}
107
108
109LongPt_Convert(PyObject *v, LongPt *p)
110{
111 return PyArg_Parse(v, "(ll)", &p->h, &p->v);
112}
113
114PyObject *
115LongPt_New(LongPt *p)
116{
117 return Py_BuildValue("(ll)", p->h, p->v);
118}
119
Jack Jansen756522f1996-05-07 15:24:01 +0000120/* Stuff for the callbacks: */
121static PyObject *callbackdict;
Jack Jansen25241d91996-05-20 11:30:45 +0000122WENewObjectUPP upp_new_handler;
123WEDisposeObjectUPP upp_dispose_handler;
124WEDrawObjectUPP upp_draw_handler;
125WEClickObjectUPP upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +0000126
127static OSErr
128any_handler(WESelector what, WEObjectReference who, PyObject *args, PyObject **rv)
129{
130 FlavorType tp;
131 PyObject *key, *func;
132
133 if ( args == NULL ) return errAECorruptData;
134
135 tp = WEGetObjectType(who);
136
137 if( (key=Py_BuildValue("O&O&", PyMac_BuildOSType, tp, PyMac_BuildOSType, what)) == NULL)
138 return errAECorruptData;
139 if( (func = PyDict_GetItem(callbackdict, key)) == NULL ) {
140 Py_DECREF(key);
141 return errAEHandlerNotFound;
142 }
143 Py_INCREF(func);
144 *rv = PyEval_CallObject(func, args);
145 Py_DECREF(func);
146 Py_DECREF(key);
147 if ( *rv == NULL ) {
148 fprintf(stderr, "--Exception in callback: ");
149 PyErr_Print();
150 return errAEReplyNotArrived;
151 }
152 return 0;
153}
154
155static pascal OSErr
156my_new_handler(Point *objectSize, 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(weNewHandler, objref, args, &rv);
163 if (!err) {
164 if (!PyMac_GetPoint(rv, objectSize) )
165 err = errAECoercionFail;
166 }
167 if ( args ) Py_DECREF(args);
168 if ( rv ) Py_DECREF(rv);
169 return err;
170}
171
172static pascal OSErr
173my_dispose_handler(WEObjectReference objref)
174{
175 PyObject *args=NULL, *rv=NULL;
176 OSErr err;
177
178 args=Py_BuildValue("(O&)", WEOObj_New, objref);
179 err = any_handler(weDisposeHandler, objref, args, &rv);
180 if ( args ) Py_DECREF(args);
181 if ( rv ) Py_DECREF(rv);
182 return err;
183}
184
185static pascal OSErr
186my_draw_handler(Rect *destRect, WEObjectReference objref)
187{
188 PyObject *args=NULL, *rv=NULL;
189 OSErr err;
190
191 args=Py_BuildValue("O&O&", PyMac_BuildRect, destRect, WEOObj_New, objref);
192 err = any_handler(weDrawHandler, objref, args, &rv);
193 if ( args ) Py_DECREF(args);
194 if ( rv ) Py_DECREF(rv);
195 return err;
196}
197
198static pascal Boolean
199my_click_handler(Point hitPt, EventModifiers modifiers,
200 unsigned long clickTime, WEObjectReference objref)
201{
202 PyObject *args=NULL, *rv=NULL;
203 int retvalue;
204 OSErr err;
205
206 args=Py_BuildValue("O&llO&", PyMac_BuildPoint, hitPt,
207 (long)modifiers, (long)clickTime, WEOObj_New, objref);
208 err = any_handler(weClickHandler, objref, args, &rv);
209 if (!err)
210 retvalue = PyInt_AsLong(rv);
211 else
212 retvalue = 0;
213 if ( args ) Py_DECREF(args);
214 if ( rv ) Py_DECREF(rv);
215 return retvalue;
216}
217
218
219
Jack Jansen90ecdf41996-04-16 14:29:15 +0000220static PyObject *waste_Error;
221
222/* ------------------------ Object type WEO ------------------------- */
223
224PyTypeObject WEO_Type;
225
226#define WEOObj_Check(x) ((x)->ob_type == &WEO_Type)
227
228typedef struct WEOObject {
229 PyObject_HEAD
230 WEObjectReference ob_itself;
231} WEOObject;
232
233PyObject *WEOObj_New(itself)
234 WEObjectReference itself;
235{
236 WEOObject *it;
237 if (itself == NULL) {
238 Py_INCREF(Py_None);
239 return Py_None;
240 }
241 it = PyObject_NEW(WEOObject, &WEO_Type);
242 if (it == NULL) return NULL;
243 it->ob_itself = itself;
244 return (PyObject *)it;
245}
246WEOObj_Convert(v, p_itself)
247 PyObject *v;
248 WEObjectReference *p_itself;
249{
250 if (!WEOObj_Check(v))
251 {
252 PyErr_SetString(PyExc_TypeError, "WEO required");
253 return 0;
254 }
255 *p_itself = ((WEOObject *)v)->ob_itself;
256 return 1;
257}
258
259static void WEOObj_dealloc(self)
260 WEOObject *self;
261{
262 /* Cleanup of self->ob_itself goes here */
263 PyMem_DEL(self);
264}
265
266static PyObject *WEOObj_WEGetObjectType(_self, _args)
267 WEOObject *_self;
268 PyObject *_args;
269{
270 PyObject *_res = NULL;
271 FlavorType _rv;
272 if (!PyArg_ParseTuple(_args, ""))
273 return NULL;
274 _rv = WEGetObjectType(_self->ob_itself);
275 _res = Py_BuildValue("O&",
276 PyMac_BuildOSType, _rv);
277 return _res;
278}
279
280static PyObject *WEOObj_WEGetObjectDataHandle(_self, _args)
281 WEOObject *_self;
282 PyObject *_args;
283{
284 PyObject *_res = NULL;
285 Handle _rv;
286 if (!PyArg_ParseTuple(_args, ""))
287 return NULL;
288 _rv = WEGetObjectDataHandle(_self->ob_itself);
289 _res = Py_BuildValue("O&",
290 ResObj_New, _rv);
291 return _res;
292}
293
294static PyObject *WEOObj_WEGetObjectSize(_self, _args)
295 WEOObject *_self;
296 PyObject *_args;
297{
298 PyObject *_res = NULL;
299 Point _rv;
300 if (!PyArg_ParseTuple(_args, ""))
301 return NULL;
302 _rv = WEGetObjectSize(_self->ob_itself);
303 _res = Py_BuildValue("O&",
304 PyMac_BuildPoint, _rv);
305 return _res;
306}
307
Jack Jansen756522f1996-05-07 15:24:01 +0000308static PyObject *WEOObj_WEGetObjectOwner(_self, _args)
309 WEOObject *_self;
310 PyObject *_args;
311{
312 PyObject *_res = NULL;
313 WEReference _rv;
314 if (!PyArg_ParseTuple(_args, ""))
315 return NULL;
316 _rv = WEGetObjectOwner(_self->ob_itself);
317 _res = Py_BuildValue("O&",
318 ExistingwasteObj_New, _rv);
319 return _res;
320}
321
Jack Jansen90ecdf41996-04-16 14:29:15 +0000322static PyObject *WEOObj_WEGetObjectRefCon(_self, _args)
323 WEOObject *_self;
324 PyObject *_args;
325{
326 PyObject *_res = NULL;
327 long _rv;
328 if (!PyArg_ParseTuple(_args, ""))
329 return NULL;
330 _rv = WEGetObjectRefCon(_self->ob_itself);
331 _res = Py_BuildValue("l",
332 _rv);
333 return _res;
334}
335
336static PyObject *WEOObj_WESetObjectRefCon(_self, _args)
337 WEOObject *_self;
338 PyObject *_args;
339{
340 PyObject *_res = NULL;
341 long refCon;
342 if (!PyArg_ParseTuple(_args, "l",
343 &refCon))
344 return NULL;
345 WESetObjectRefCon(_self->ob_itself,
346 refCon);
347 Py_INCREF(Py_None);
348 _res = Py_None;
349 return _res;
350}
351
352static PyMethodDef WEOObj_methods[] = {
353 {"WEGetObjectType", (PyCFunction)WEOObj_WEGetObjectType, 1,
354 "() -> (FlavorType _rv)"},
355 {"WEGetObjectDataHandle", (PyCFunction)WEOObj_WEGetObjectDataHandle, 1,
356 "() -> (Handle _rv)"},
357 {"WEGetObjectSize", (PyCFunction)WEOObj_WEGetObjectSize, 1,
358 "() -> (Point _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +0000359 {"WEGetObjectOwner", (PyCFunction)WEOObj_WEGetObjectOwner, 1,
360 "() -> (WEReference _rv)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +0000361 {"WEGetObjectRefCon", (PyCFunction)WEOObj_WEGetObjectRefCon, 1,
362 "() -> (long _rv)"},
363 {"WESetObjectRefCon", (PyCFunction)WEOObj_WESetObjectRefCon, 1,
364 "(long refCon) -> None"},
365 {NULL, NULL, 0}
366};
367
368PyMethodChain WEOObj_chain = { WEOObj_methods, NULL };
369
370static PyObject *WEOObj_getattr(self, name)
371 WEOObject *self;
372 char *name;
373{
374 return Py_FindMethodInChain(&WEOObj_chain, (PyObject *)self, name);
375}
376
377#define WEOObj_setattr NULL
378
379PyTypeObject WEO_Type = {
380 PyObject_HEAD_INIT(&PyType_Type)
381 0, /*ob_size*/
382 "WEO", /*tp_name*/
383 sizeof(WEOObject), /*tp_basicsize*/
384 0, /*tp_itemsize*/
385 /* methods */
386 (destructor) WEOObj_dealloc, /*tp_dealloc*/
387 0, /*tp_print*/
388 (getattrfunc) WEOObj_getattr, /*tp_getattr*/
389 (setattrfunc) WEOObj_setattr, /*tp_setattr*/
390};
391
392/* ---------------------- End object type WEO ----------------------- */
393
394
395/* ----------------------- Object type waste ------------------------ */
396
397PyTypeObject waste_Type;
398
399#define wasteObj_Check(x) ((x)->ob_type == &waste_Type)
400
401typedef struct wasteObject {
402 PyObject_HEAD
403 WEReference ob_itself;
404} wasteObject;
405
406PyObject *wasteObj_New(itself)
407 WEReference itself;
408{
409 wasteObject *it;
410 if (itself == NULL) {
411 PyErr_SetString(waste_Error,"Cannot create null WE");
412 return NULL;
413 }
414 it = PyObject_NEW(wasteObject, &waste_Type);
415 if (it == NULL) return NULL;
416 it->ob_itself = itself;
Jack Jansen756522f1996-05-07 15:24:01 +0000417 WESetInfo(weRefCon, (void *)&it, itself);
Jack Jansen90ecdf41996-04-16 14:29:15 +0000418 return (PyObject *)it;
419}
420wasteObj_Convert(v, p_itself)
421 PyObject *v;
422 WEReference *p_itself;
423{
424 if (!wasteObj_Check(v))
425 {
426 PyErr_SetString(PyExc_TypeError, "waste required");
427 return 0;
428 }
429 *p_itself = ((wasteObject *)v)->ob_itself;
430 return 1;
431}
432
433static void wasteObj_dealloc(self)
434 wasteObject *self;
435{
436 WEDispose(self->ob_itself);
437 PyMem_DEL(self);
438}
439
440static PyObject *wasteObj_WEGetText(_self, _args)
441 wasteObject *_self;
442 PyObject *_args;
443{
444 PyObject *_res = NULL;
445 Handle _rv;
446 if (!PyArg_ParseTuple(_args, ""))
447 return NULL;
448 _rv = WEGetText(_self->ob_itself);
449 _res = Py_BuildValue("O&",
450 ResObj_New, _rv);
451 return _res;
452}
453
454static PyObject *wasteObj_WEGetChar(_self, _args)
455 wasteObject *_self;
456 PyObject *_args;
457{
458 PyObject *_res = NULL;
459 short _rv;
460 long offset;
461 if (!PyArg_ParseTuple(_args, "l",
462 &offset))
463 return NULL;
464 _rv = WEGetChar(offset,
465 _self->ob_itself);
466 _res = Py_BuildValue("h",
467 _rv);
468 return _res;
469}
470
471static PyObject *wasteObj_WEGetTextLength(_self, _args)
472 wasteObject *_self;
473 PyObject *_args;
474{
475 PyObject *_res = NULL;
476 long _rv;
477 if (!PyArg_ParseTuple(_args, ""))
478 return NULL;
479 _rv = WEGetTextLength(_self->ob_itself);
480 _res = Py_BuildValue("l",
481 _rv);
482 return _res;
483}
484
485static PyObject *wasteObj_WECountLines(_self, _args)
486 wasteObject *_self;
487 PyObject *_args;
488{
489 PyObject *_res = NULL;
490 long _rv;
491 if (!PyArg_ParseTuple(_args, ""))
492 return NULL;
493 _rv = WECountLines(_self->ob_itself);
494 _res = Py_BuildValue("l",
495 _rv);
496 return _res;
497}
498
499static PyObject *wasteObj_WEGetHeight(_self, _args)
500 wasteObject *_self;
501 PyObject *_args;
502{
503 PyObject *_res = NULL;
504 long _rv;
505 long startLine;
506 long endLine;
507 if (!PyArg_ParseTuple(_args, "ll",
508 &startLine,
509 &endLine))
510 return NULL;
511 _rv = WEGetHeight(startLine,
512 endLine,
513 _self->ob_itself);
514 _res = Py_BuildValue("l",
515 _rv);
516 return _res;
517}
518
519static PyObject *wasteObj_WEGetSelection(_self, _args)
520 wasteObject *_self;
521 PyObject *_args;
522{
523 PyObject *_res = NULL;
524 long selStart;
525 long selEnd;
526 if (!PyArg_ParseTuple(_args, ""))
527 return NULL;
528 WEGetSelection(&selStart,
529 &selEnd,
530 _self->ob_itself);
531 _res = Py_BuildValue("ll",
532 selStart,
533 selEnd);
534 return _res;
535}
536
537static PyObject *wasteObj_WEGetDestRect(_self, _args)
538 wasteObject *_self;
539 PyObject *_args;
540{
541 PyObject *_res = NULL;
542 LongRect destRect;
543 if (!PyArg_ParseTuple(_args, ""))
544 return NULL;
545 WEGetDestRect(&destRect,
546 _self->ob_itself);
547 _res = Py_BuildValue("O&",
548 LongRect_New, &destRect);
549 return _res;
550}
551
552static PyObject *wasteObj_WEGetViewRect(_self, _args)
553 wasteObject *_self;
554 PyObject *_args;
555{
556 PyObject *_res = NULL;
557 LongRect viewRect;
558 if (!PyArg_ParseTuple(_args, ""))
559 return NULL;
560 WEGetViewRect(&viewRect,
561 _self->ob_itself);
562 _res = Py_BuildValue("O&",
563 LongRect_New, &viewRect);
564 return _res;
565}
566
567static PyObject *wasteObj_WEIsActive(_self, _args)
568 wasteObject *_self;
569 PyObject *_args;
570{
571 PyObject *_res = NULL;
572 Boolean _rv;
573 if (!PyArg_ParseTuple(_args, ""))
574 return NULL;
575 _rv = WEIsActive(_self->ob_itself);
576 _res = Py_BuildValue("b",
577 _rv);
578 return _res;
579}
580
581static PyObject *wasteObj_WEOffsetToLine(_self, _args)
582 wasteObject *_self;
583 PyObject *_args;
584{
585 PyObject *_res = NULL;
586 long _rv;
587 long offset;
588 if (!PyArg_ParseTuple(_args, "l",
589 &offset))
590 return NULL;
591 _rv = WEOffsetToLine(offset,
592 _self->ob_itself);
593 _res = Py_BuildValue("l",
594 _rv);
595 return _res;
596}
597
598static PyObject *wasteObj_WEGetLineRange(_self, _args)
599 wasteObject *_self;
600 PyObject *_args;
601{
602 PyObject *_res = NULL;
603 long lineNo;
604 long lineStart;
605 long lineEnd;
606 if (!PyArg_ParseTuple(_args, "l",
607 &lineNo))
608 return NULL;
609 WEGetLineRange(lineNo,
610 &lineStart,
611 &lineEnd,
612 _self->ob_itself);
613 _res = Py_BuildValue("ll",
614 lineStart,
615 lineEnd);
616 return _res;
617}
618
619static PyObject *wasteObj_WESetSelection(_self, _args)
620 wasteObject *_self;
621 PyObject *_args;
622{
623 PyObject *_res = NULL;
624 long selStart;
625 long selEnd;
626 if (!PyArg_ParseTuple(_args, "ll",
627 &selStart,
628 &selEnd))
629 return NULL;
630 WESetSelection(selStart,
631 selEnd,
632 _self->ob_itself);
633 Py_INCREF(Py_None);
634 _res = Py_None;
635 return _res;
636}
637
638static PyObject *wasteObj_WESetDestRect(_self, _args)
639 wasteObject *_self;
640 PyObject *_args;
641{
642 PyObject *_res = NULL;
643 LongRect destRect;
644 if (!PyArg_ParseTuple(_args, "O&",
645 LongRect_Convert, &destRect))
646 return NULL;
647 WESetDestRect(&destRect,
648 _self->ob_itself);
649 Py_INCREF(Py_None);
650 _res = Py_None;
651 return _res;
652}
653
654static PyObject *wasteObj_WESetViewRect(_self, _args)
655 wasteObject *_self;
656 PyObject *_args;
657{
658 PyObject *_res = NULL;
659 LongRect viewRect;
660 if (!PyArg_ParseTuple(_args, "O&",
661 LongRect_Convert, &viewRect))
662 return NULL;
663 WESetViewRect(&viewRect,
664 _self->ob_itself);
665 Py_INCREF(Py_None);
666 _res = Py_None;
667 return _res;
668}
669
670static PyObject *wasteObj_WEContinuousStyle(_self, _args)
671 wasteObject *_self;
672 PyObject *_args;
673{
674 PyObject *_res = NULL;
675 Boolean _rv;
676 WEStyleMode mode;
677 TextStyle ts;
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000678 if (!PyArg_ParseTuple(_args, "h",
679 &mode))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000680 return NULL;
681 _rv = WEContinuousStyle(&mode,
682 &ts,
683 _self->ob_itself);
684 _res = Py_BuildValue("bhO&",
685 _rv,
686 mode,
687 TextStyle_New, &ts);
688 return _res;
689}
690
691static PyObject *wasteObj_WEGetRunInfo(_self, _args)
692 wasteObject *_self;
693 PyObject *_args;
694{
695 PyObject *_res = NULL;
696 long offset;
697 WERunInfo runInfo;
698 if (!PyArg_ParseTuple(_args, "l",
699 &offset))
700 return NULL;
701 WEGetRunInfo(offset,
702 &runInfo,
703 _self->ob_itself);
704 _res = Py_BuildValue("O&",
705 RunInfo_New, &runInfo);
706 return _res;
707}
708
709static PyObject *wasteObj_WEGetOffset(_self, _args)
710 wasteObject *_self;
711 PyObject *_args;
712{
713 PyObject *_res = NULL;
714 long _rv;
715 LongPt thePoint;
716 char edge;
717 if (!PyArg_ParseTuple(_args, "O&",
718 LongPt_Convert, &thePoint))
719 return NULL;
720 _rv = WEGetOffset(&thePoint,
721 &edge,
722 _self->ob_itself);
723 _res = Py_BuildValue("lc",
724 _rv,
725 edge);
726 return _res;
727}
728
729static PyObject *wasteObj_WEGetPoint(_self, _args)
730 wasteObject *_self;
731 PyObject *_args;
732{
733 PyObject *_res = NULL;
734 long offset;
735 LongPt thePoint;
736 short lineHeight;
737 if (!PyArg_ParseTuple(_args, "l",
738 &offset))
739 return NULL;
740 WEGetPoint(offset,
741 &thePoint,
742 &lineHeight,
743 _self->ob_itself);
744 _res = Py_BuildValue("O&h",
745 LongPt_New, &thePoint,
746 lineHeight);
747 return _res;
748}
749
750static PyObject *wasteObj_WEFindWord(_self, _args)
751 wasteObject *_self;
752 PyObject *_args;
753{
754 PyObject *_res = NULL;
755 long offset;
756 char edge;
757 long wordStart;
758 long wordEnd;
759 if (!PyArg_ParseTuple(_args, "lc",
760 &offset,
761 &edge))
762 return NULL;
763 WEFindWord(offset,
764 edge,
765 &wordStart,
766 &wordEnd,
767 _self->ob_itself);
768 _res = Py_BuildValue("ll",
769 wordStart,
770 wordEnd);
771 return _res;
772}
773
774static PyObject *wasteObj_WEFindLine(_self, _args)
775 wasteObject *_self;
776 PyObject *_args;
777{
778 PyObject *_res = NULL;
779 long offset;
780 char edge;
781 long lineStart;
782 long lineEnd;
783 if (!PyArg_ParseTuple(_args, "lc",
784 &offset,
785 &edge))
786 return NULL;
787 WEFindLine(offset,
788 edge,
789 &lineStart,
790 &lineEnd,
791 _self->ob_itself);
792 _res = Py_BuildValue("ll",
793 lineStart,
794 lineEnd);
795 return _res;
796}
797
798static PyObject *wasteObj_WECopyRange(_self, _args)
799 wasteObject *_self;
800 PyObject *_args;
801{
802 PyObject *_res = NULL;
803 OSErr _err;
804 long rangeStart;
805 long rangeEnd;
806 Handle hText;
807 StScrpHandle hStyles;
808 WESoupHandle hSoup;
809 if (!PyArg_ParseTuple(_args, "llO&O&O&",
810 &rangeStart,
811 &rangeEnd,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +0000812 OptResObj_Convert, &hText,
813 OptResObj_Convert, &hStyles,
814 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +0000815 return NULL;
816 _err = WECopyRange(rangeStart,
817 rangeEnd,
818 hText,
819 hStyles,
820 hSoup,
821 _self->ob_itself);
822 if (_err != noErr) return PyMac_Error(_err);
823 Py_INCREF(Py_None);
824 _res = Py_None;
825 return _res;
826}
827
828static PyObject *wasteObj_WEGetAlignment(_self, _args)
829 wasteObject *_self;
830 PyObject *_args;
831{
832 PyObject *_res = NULL;
833 WEAlignment _rv;
834 if (!PyArg_ParseTuple(_args, ""))
835 return NULL;
836 _rv = WEGetAlignment(_self->ob_itself);
837 _res = Py_BuildValue("b",
838 _rv);
839 return _res;
840}
841
842static PyObject *wasteObj_WESetAlignment(_self, _args)
843 wasteObject *_self;
844 PyObject *_args;
845{
846 PyObject *_res = NULL;
847 WEAlignment alignment;
848 if (!PyArg_ParseTuple(_args, "b",
849 &alignment))
850 return NULL;
851 WESetAlignment(alignment,
852 _self->ob_itself);
853 Py_INCREF(Py_None);
854 _res = Py_None;
855 return _res;
856}
857
858static PyObject *wasteObj_WECalText(_self, _args)
859 wasteObject *_self;
860 PyObject *_args;
861{
862 PyObject *_res = NULL;
863 OSErr _err;
864 if (!PyArg_ParseTuple(_args, ""))
865 return NULL;
866 _err = WECalText(_self->ob_itself);
867 if (_err != noErr) return PyMac_Error(_err);
868 Py_INCREF(Py_None);
869 _res = Py_None;
870 return _res;
871}
872
873static PyObject *wasteObj_WEUpdate(_self, _args)
874 wasteObject *_self;
875 PyObject *_args;
876{
877 PyObject *_res = NULL;
878 RgnHandle updateRgn;
879 if (!PyArg_ParseTuple(_args, "O&",
880 ResObj_Convert, &updateRgn))
881 return NULL;
882 WEUpdate(updateRgn,
883 _self->ob_itself);
884 Py_INCREF(Py_None);
885 _res = Py_None;
886 return _res;
887}
888
889static PyObject *wasteObj_WEScroll(_self, _args)
890 wasteObject *_self;
891 PyObject *_args;
892{
893 PyObject *_res = NULL;
894 long hOffset;
895 long vOffset;
896 if (!PyArg_ParseTuple(_args, "ll",
897 &hOffset,
898 &vOffset))
899 return NULL;
900 WEScroll(hOffset,
901 vOffset,
902 _self->ob_itself);
903 Py_INCREF(Py_None);
904 _res = Py_None;
905 return _res;
906}
907
908static PyObject *wasteObj_WESelView(_self, _args)
909 wasteObject *_self;
910 PyObject *_args;
911{
912 PyObject *_res = NULL;
913 if (!PyArg_ParseTuple(_args, ""))
914 return NULL;
915 WESelView(_self->ob_itself);
916 Py_INCREF(Py_None);
917 _res = Py_None;
918 return _res;
919}
920
921static PyObject *wasteObj_WEActivate(_self, _args)
922 wasteObject *_self;
923 PyObject *_args;
924{
925 PyObject *_res = NULL;
926 if (!PyArg_ParseTuple(_args, ""))
927 return NULL;
928 WEActivate(_self->ob_itself);
929 Py_INCREF(Py_None);
930 _res = Py_None;
931 return _res;
932}
933
934static PyObject *wasteObj_WEDeactivate(_self, _args)
935 wasteObject *_self;
936 PyObject *_args;
937{
938 PyObject *_res = NULL;
939 if (!PyArg_ParseTuple(_args, ""))
940 return NULL;
941 WEDeactivate(_self->ob_itself);
942 Py_INCREF(Py_None);
943 _res = Py_None;
944 return _res;
945}
946
947static PyObject *wasteObj_WEKey(_self, _args)
948 wasteObject *_self;
949 PyObject *_args;
950{
951 PyObject *_res = NULL;
952 short key;
953 EventModifiers modifiers;
954 if (!PyArg_ParseTuple(_args, "hh",
955 &key,
956 &modifiers))
957 return NULL;
958 WEKey(key,
959 modifiers,
960 _self->ob_itself);
961 Py_INCREF(Py_None);
962 _res = Py_None;
963 return _res;
964}
965
966static PyObject *wasteObj_WEClick(_self, _args)
967 wasteObject *_self;
968 PyObject *_args;
969{
970 PyObject *_res = NULL;
971 Point hitPt;
972 EventModifiers modifiers;
973 unsigned long clickTime;
974 if (!PyArg_ParseTuple(_args, "O&hl",
975 PyMac_GetPoint, &hitPt,
976 &modifiers,
977 &clickTime))
978 return NULL;
979 WEClick(hitPt,
980 modifiers,
981 clickTime,
982 _self->ob_itself);
983 Py_INCREF(Py_None);
984 _res = Py_None;
985 return _res;
986}
987
988static PyObject *wasteObj_WEAdjustCursor(_self, _args)
989 wasteObject *_self;
990 PyObject *_args;
991{
992 PyObject *_res = NULL;
993 Boolean _rv;
994 Point mouseLoc;
995 RgnHandle mouseRgn;
996 if (!PyArg_ParseTuple(_args, "O&O&",
997 PyMac_GetPoint, &mouseLoc,
998 ResObj_Convert, &mouseRgn))
999 return NULL;
1000 _rv = WEAdjustCursor(mouseLoc,
1001 mouseRgn,
1002 _self->ob_itself);
1003 _res = Py_BuildValue("b",
1004 _rv);
1005 return _res;
1006}
1007
1008static PyObject *wasteObj_WEIdle(_self, _args)
1009 wasteObject *_self;
1010 PyObject *_args;
1011{
1012 PyObject *_res = NULL;
1013 unsigned long maxSleep;
1014 if (!PyArg_ParseTuple(_args, ""))
1015 return NULL;
1016 WEIdle(&maxSleep,
1017 _self->ob_itself);
1018 _res = Py_BuildValue("l",
1019 maxSleep);
1020 return _res;
1021}
1022
1023static PyObject *wasteObj_WEInsert(_self, _args)
1024 wasteObject *_self;
1025 PyObject *_args;
1026{
1027 PyObject *_res = NULL;
1028 OSErr _err;
1029 char *pText__in__;
1030 long pText__len__;
1031 int pText__in_len__;
1032 StScrpHandle hStyles;
1033 WESoupHandle hSoup;
1034 if (!PyArg_ParseTuple(_args, "s#O&O&",
1035 &pText__in__, &pText__in_len__,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001036 OptResObj_Convert, &hStyles,
1037 OptResObj_Convert, &hSoup))
Jack Jansen90ecdf41996-04-16 14:29:15 +00001038 return NULL;
1039 pText__len__ = pText__in_len__;
1040 _err = WEInsert(pText__in__, pText__len__,
1041 hStyles,
1042 hSoup,
1043 _self->ob_itself);
1044 if (_err != noErr) return PyMac_Error(_err);
1045 Py_INCREF(Py_None);
1046 _res = Py_None;
1047 pText__error__: ;
1048 return _res;
1049}
1050
1051static PyObject *wasteObj_WEDelete(_self, _args)
1052 wasteObject *_self;
1053 PyObject *_args;
1054{
1055 PyObject *_res = NULL;
1056 OSErr _err;
1057 if (!PyArg_ParseTuple(_args, ""))
1058 return NULL;
1059 _err = WEDelete(_self->ob_itself);
1060 if (_err != noErr) return PyMac_Error(_err);
1061 Py_INCREF(Py_None);
1062 _res = Py_None;
1063 return _res;
1064}
1065
1066static PyObject *wasteObj_WESetStyle(_self, _args)
1067 wasteObject *_self;
1068 PyObject *_args;
1069{
1070 PyObject *_res = NULL;
1071 OSErr _err;
1072 WEStyleMode mode;
1073 TextStyle ts;
1074 if (!PyArg_ParseTuple(_args, "hO&",
1075 &mode,
1076 TextStyle_Convert, &ts))
1077 return NULL;
1078 _err = WESetStyle(mode,
1079 &ts,
1080 _self->ob_itself);
1081 if (_err != noErr) return PyMac_Error(_err);
1082 Py_INCREF(Py_None);
1083 _res = Py_None;
1084 return _res;
1085}
1086
1087static PyObject *wasteObj_WEUseStyleScrap(_self, _args)
1088 wasteObject *_self;
1089 PyObject *_args;
1090{
1091 PyObject *_res = NULL;
1092 OSErr _err;
1093 StScrpHandle hStyles;
1094 if (!PyArg_ParseTuple(_args, "O&",
1095 ResObj_Convert, &hStyles))
1096 return NULL;
1097 _err = WEUseStyleScrap(hStyles,
1098 _self->ob_itself);
1099 if (_err != noErr) return PyMac_Error(_err);
1100 Py_INCREF(Py_None);
1101 _res = Py_None;
1102 return _res;
1103}
1104
1105static PyObject *wasteObj_WEUseText(_self, _args)
1106 wasteObject *_self;
1107 PyObject *_args;
1108{
1109 PyObject *_res = NULL;
1110 OSErr _err;
1111 Handle hText;
1112 if (!PyArg_ParseTuple(_args, "O&",
1113 ResObj_Convert, &hText))
1114 return NULL;
1115 _err = WEUseText(hText,
1116 _self->ob_itself);
1117 if (_err != noErr) return PyMac_Error(_err);
1118 Py_INCREF(Py_None);
1119 _res = Py_None;
1120 return _res;
1121}
1122
1123static PyObject *wasteObj_WEUndo(_self, _args)
1124 wasteObject *_self;
1125 PyObject *_args;
1126{
1127 PyObject *_res = NULL;
1128 OSErr _err;
1129 if (!PyArg_ParseTuple(_args, ""))
1130 return NULL;
1131 _err = WEUndo(_self->ob_itself);
1132 if (_err != noErr) return PyMac_Error(_err);
1133 Py_INCREF(Py_None);
1134 _res = Py_None;
1135 return _res;
1136}
1137
1138static PyObject *wasteObj_WEClearUndo(_self, _args)
1139 wasteObject *_self;
1140 PyObject *_args;
1141{
1142 PyObject *_res = NULL;
1143 if (!PyArg_ParseTuple(_args, ""))
1144 return NULL;
1145 WEClearUndo(_self->ob_itself);
1146 Py_INCREF(Py_None);
1147 _res = Py_None;
1148 return _res;
1149}
1150
1151static PyObject *wasteObj_WEGetUndoInfo(_self, _args)
1152 wasteObject *_self;
1153 PyObject *_args;
1154{
1155 PyObject *_res = NULL;
1156 WEActionKind _rv;
1157 Boolean redoFlag;
1158 if (!PyArg_ParseTuple(_args, ""))
1159 return NULL;
1160 _rv = WEGetUndoInfo(&redoFlag,
1161 _self->ob_itself);
1162 _res = Py_BuildValue("hb",
1163 _rv,
1164 redoFlag);
1165 return _res;
1166}
1167
1168static PyObject *wasteObj_WEIsTyping(_self, _args)
1169 wasteObject *_self;
1170 PyObject *_args;
1171{
1172 PyObject *_res = NULL;
1173 Boolean _rv;
1174 if (!PyArg_ParseTuple(_args, ""))
1175 return NULL;
1176 _rv = WEIsTyping(_self->ob_itself);
1177 _res = Py_BuildValue("b",
1178 _rv);
1179 return _res;
1180}
1181
1182static PyObject *wasteObj_WEGetModCount(_self, _args)
1183 wasteObject *_self;
1184 PyObject *_args;
1185{
1186 PyObject *_res = NULL;
1187 unsigned long _rv;
1188 if (!PyArg_ParseTuple(_args, ""))
1189 return NULL;
1190 _rv = WEGetModCount(_self->ob_itself);
1191 _res = Py_BuildValue("l",
1192 _rv);
1193 return _res;
1194}
1195
1196static PyObject *wasteObj_WEResetModCount(_self, _args)
1197 wasteObject *_self;
1198 PyObject *_args;
1199{
1200 PyObject *_res = NULL;
1201 if (!PyArg_ParseTuple(_args, ""))
1202 return NULL;
1203 WEResetModCount(_self->ob_itself);
1204 Py_INCREF(Py_None);
1205 _res = Py_None;
1206 return _res;
1207}
1208
1209static PyObject *wasteObj_WEInsertObject(_self, _args)
1210 wasteObject *_self;
1211 PyObject *_args;
1212{
1213 PyObject *_res = NULL;
1214 OSErr _err;
1215 FlavorType objectType;
1216 Handle objectDataHandle;
1217 Point objectSize;
1218 if (!PyArg_ParseTuple(_args, "O&O&O&",
1219 PyMac_GetOSType, &objectType,
1220 ResObj_Convert, &objectDataHandle,
1221 PyMac_GetPoint, &objectSize))
1222 return NULL;
1223 _err = WEInsertObject(objectType,
1224 objectDataHandle,
1225 objectSize,
1226 _self->ob_itself);
1227 if (_err != noErr) return PyMac_Error(_err);
1228 Py_INCREF(Py_None);
1229 _res = Py_None;
1230 return _res;
1231}
1232
1233static PyObject *wasteObj_WEGetSelectedObject(_self, _args)
1234 wasteObject *_self;
1235 PyObject *_args;
1236{
1237 PyObject *_res = NULL;
1238 OSErr _err;
1239 WEObjectReference obj;
1240 if (!PyArg_ParseTuple(_args, ""))
1241 return NULL;
1242 _err = WEGetSelectedObject(&obj,
1243 _self->ob_itself);
1244 if (_err != noErr) return PyMac_Error(_err);
1245 _res = Py_BuildValue("O&",
1246 WEOObj_New, obj);
1247 return _res;
1248}
1249
1250static PyObject *wasteObj_WEFindNextObject(_self, _args)
1251 wasteObject *_self;
1252 PyObject *_args;
1253{
1254 PyObject *_res = NULL;
1255 long _rv;
1256 long offset;
1257 WEObjectReference obj;
1258 if (!PyArg_ParseTuple(_args, "l",
1259 &offset))
1260 return NULL;
1261 _rv = WEFindNextObject(offset,
1262 &obj,
1263 _self->ob_itself);
1264 _res = Py_BuildValue("lO&",
1265 _rv,
1266 WEOObj_New, obj);
1267 return _res;
1268}
1269
1270static PyObject *wasteObj_WEUseSoup(_self, _args)
1271 wasteObject *_self;
1272 PyObject *_args;
1273{
1274 PyObject *_res = NULL;
1275 OSErr _err;
1276 WESoupHandle hSoup;
1277 if (!PyArg_ParseTuple(_args, "O&",
1278 ResObj_Convert, &hSoup))
1279 return NULL;
1280 _err = WEUseSoup(hSoup,
1281 _self->ob_itself);
1282 if (_err != noErr) return PyMac_Error(_err);
1283 Py_INCREF(Py_None);
1284 _res = Py_None;
1285 return _res;
1286}
1287
1288static PyObject *wasteObj_WECut(_self, _args)
1289 wasteObject *_self;
1290 PyObject *_args;
1291{
1292 PyObject *_res = NULL;
1293 OSErr _err;
1294 if (!PyArg_ParseTuple(_args, ""))
1295 return NULL;
1296 _err = WECut(_self->ob_itself);
1297 if (_err != noErr) return PyMac_Error(_err);
1298 Py_INCREF(Py_None);
1299 _res = Py_None;
1300 return _res;
1301}
1302
1303static PyObject *wasteObj_WECopy(_self, _args)
1304 wasteObject *_self;
1305 PyObject *_args;
1306{
1307 PyObject *_res = NULL;
1308 OSErr _err;
1309 if (!PyArg_ParseTuple(_args, ""))
1310 return NULL;
1311 _err = WECopy(_self->ob_itself);
1312 if (_err != noErr) return PyMac_Error(_err);
1313 Py_INCREF(Py_None);
1314 _res = Py_None;
1315 return _res;
1316}
1317
1318static PyObject *wasteObj_WEPaste(_self, _args)
1319 wasteObject *_self;
1320 PyObject *_args;
1321{
1322 PyObject *_res = NULL;
1323 OSErr _err;
1324 if (!PyArg_ParseTuple(_args, ""))
1325 return NULL;
1326 _err = WEPaste(_self->ob_itself);
1327 if (_err != noErr) return PyMac_Error(_err);
1328 Py_INCREF(Py_None);
1329 _res = Py_None;
1330 return _res;
1331}
1332
1333static PyObject *wasteObj_WECanPaste(_self, _args)
1334 wasteObject *_self;
1335 PyObject *_args;
1336{
1337 PyObject *_res = NULL;
1338 Boolean _rv;
1339 if (!PyArg_ParseTuple(_args, ""))
1340 return NULL;
1341 _rv = WECanPaste(_self->ob_itself);
1342 _res = Py_BuildValue("b",
1343 _rv);
1344 return _res;
1345}
1346
1347static PyObject *wasteObj_WEGetHiliteRgn(_self, _args)
1348 wasteObject *_self;
1349 PyObject *_args;
1350{
1351 PyObject *_res = NULL;
1352 RgnHandle _rv;
1353 long rangeStart;
1354 long rangeEnd;
1355 if (!PyArg_ParseTuple(_args, "ll",
1356 &rangeStart,
1357 &rangeEnd))
1358 return NULL;
1359 _rv = WEGetHiliteRgn(rangeStart,
1360 rangeEnd,
1361 _self->ob_itself);
1362 _res = Py_BuildValue("O&",
1363 ResObj_New, _rv);
1364 return _res;
1365}
1366
1367static PyObject *wasteObj_WECharByte(_self, _args)
1368 wasteObject *_self;
1369 PyObject *_args;
1370{
1371 PyObject *_res = NULL;
1372 short _rv;
1373 long offset;
1374 if (!PyArg_ParseTuple(_args, "l",
1375 &offset))
1376 return NULL;
1377 _rv = WECharByte(offset,
1378 _self->ob_itself);
1379 _res = Py_BuildValue("h",
1380 _rv);
1381 return _res;
1382}
1383
1384static PyObject *wasteObj_WECharType(_self, _args)
1385 wasteObject *_self;
1386 PyObject *_args;
1387{
1388 PyObject *_res = NULL;
1389 short _rv;
1390 long offset;
1391 if (!PyArg_ParseTuple(_args, "l",
1392 &offset))
1393 return NULL;
1394 _rv = WECharType(offset,
1395 _self->ob_itself);
1396 _res = Py_BuildValue("h",
1397 _rv);
1398 return _res;
1399}
1400
1401static PyObject *wasteObj_WEStopInlineSession(_self, _args)
1402 wasteObject *_self;
1403 PyObject *_args;
1404{
1405 PyObject *_res = NULL;
1406 if (!PyArg_ParseTuple(_args, ""))
1407 return NULL;
1408 WEStopInlineSession(_self->ob_itself);
1409 Py_INCREF(Py_None);
1410 _res = Py_None;
1411 return _res;
1412}
1413
1414static PyObject *wasteObj_WEFeatureFlag(_self, _args)
1415 wasteObject *_self;
1416 PyObject *_args;
1417{
1418 PyObject *_res = NULL;
1419 short _rv;
1420 short feature;
1421 short action;
1422 if (!PyArg_ParseTuple(_args, "hh",
1423 &feature,
1424 &action))
1425 return NULL;
1426 _rv = WEFeatureFlag(feature,
1427 action,
1428 _self->ob_itself);
1429 _res = Py_BuildValue("h",
1430 _rv);
1431 return _res;
1432}
1433
1434static PyMethodDef wasteObj_methods[] = {
1435 {"WEGetText", (PyCFunction)wasteObj_WEGetText, 1,
1436 "() -> (Handle _rv)"},
1437 {"WEGetChar", (PyCFunction)wasteObj_WEGetChar, 1,
1438 "(long offset) -> (short _rv)"},
1439 {"WEGetTextLength", (PyCFunction)wasteObj_WEGetTextLength, 1,
1440 "() -> (long _rv)"},
1441 {"WECountLines", (PyCFunction)wasteObj_WECountLines, 1,
1442 "() -> (long _rv)"},
1443 {"WEGetHeight", (PyCFunction)wasteObj_WEGetHeight, 1,
1444 "(long startLine, long endLine) -> (long _rv)"},
1445 {"WEGetSelection", (PyCFunction)wasteObj_WEGetSelection, 1,
1446 "() -> (long selStart, long selEnd)"},
1447 {"WEGetDestRect", (PyCFunction)wasteObj_WEGetDestRect, 1,
1448 "() -> (LongRect destRect)"},
1449 {"WEGetViewRect", (PyCFunction)wasteObj_WEGetViewRect, 1,
1450 "() -> (LongRect viewRect)"},
1451 {"WEIsActive", (PyCFunction)wasteObj_WEIsActive, 1,
1452 "() -> (Boolean _rv)"},
1453 {"WEOffsetToLine", (PyCFunction)wasteObj_WEOffsetToLine, 1,
1454 "(long offset) -> (long _rv)"},
1455 {"WEGetLineRange", (PyCFunction)wasteObj_WEGetLineRange, 1,
1456 "(long lineNo) -> (long lineStart, long lineEnd)"},
1457 {"WESetSelection", (PyCFunction)wasteObj_WESetSelection, 1,
1458 "(long selStart, long selEnd) -> None"},
1459 {"WESetDestRect", (PyCFunction)wasteObj_WESetDestRect, 1,
1460 "(LongRect destRect) -> None"},
1461 {"WESetViewRect", (PyCFunction)wasteObj_WESetViewRect, 1,
1462 "(LongRect viewRect) -> None"},
1463 {"WEContinuousStyle", (PyCFunction)wasteObj_WEContinuousStyle, 1,
Jack Jansen8ae8e4f1996-04-23 16:17:08 +00001464 "(WEStyleMode mode) -> (Boolean _rv, WEStyleMode mode, TextStyle ts)"},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001465 {"WEGetRunInfo", (PyCFunction)wasteObj_WEGetRunInfo, 1,
1466 "(long offset) -> (WERunInfo runInfo)"},
1467 {"WEGetOffset", (PyCFunction)wasteObj_WEGetOffset, 1,
1468 "(LongPt thePoint) -> (long _rv, char edge)"},
1469 {"WEGetPoint", (PyCFunction)wasteObj_WEGetPoint, 1,
1470 "(long offset) -> (LongPt thePoint, short lineHeight)"},
1471 {"WEFindWord", (PyCFunction)wasteObj_WEFindWord, 1,
1472 "(long offset, char edge) -> (long wordStart, long wordEnd)"},
1473 {"WEFindLine", (PyCFunction)wasteObj_WEFindLine, 1,
1474 "(long offset, char edge) -> (long lineStart, long lineEnd)"},
1475 {"WECopyRange", (PyCFunction)wasteObj_WECopyRange, 1,
1476 "(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1477 {"WEGetAlignment", (PyCFunction)wasteObj_WEGetAlignment, 1,
1478 "() -> (WEAlignment _rv)"},
1479 {"WESetAlignment", (PyCFunction)wasteObj_WESetAlignment, 1,
1480 "(WEAlignment alignment) -> None"},
1481 {"WECalText", (PyCFunction)wasteObj_WECalText, 1,
1482 "() -> None"},
1483 {"WEUpdate", (PyCFunction)wasteObj_WEUpdate, 1,
1484 "(RgnHandle updateRgn) -> None"},
1485 {"WEScroll", (PyCFunction)wasteObj_WEScroll, 1,
1486 "(long hOffset, long vOffset) -> None"},
1487 {"WESelView", (PyCFunction)wasteObj_WESelView, 1,
1488 "() -> None"},
1489 {"WEActivate", (PyCFunction)wasteObj_WEActivate, 1,
1490 "() -> None"},
1491 {"WEDeactivate", (PyCFunction)wasteObj_WEDeactivate, 1,
1492 "() -> None"},
1493 {"WEKey", (PyCFunction)wasteObj_WEKey, 1,
1494 "(short key, EventModifiers modifiers) -> None"},
1495 {"WEClick", (PyCFunction)wasteObj_WEClick, 1,
1496 "(Point hitPt, EventModifiers modifiers, unsigned long clickTime) -> None"},
1497 {"WEAdjustCursor", (PyCFunction)wasteObj_WEAdjustCursor, 1,
1498 "(Point mouseLoc, RgnHandle mouseRgn) -> (Boolean _rv)"},
1499 {"WEIdle", (PyCFunction)wasteObj_WEIdle, 1,
1500 "() -> (unsigned long maxSleep)"},
1501 {"WEInsert", (PyCFunction)wasteObj_WEInsert, 1,
1502 "(Buffer pText, StScrpHandle hStyles, WESoupHandle hSoup) -> None"},
1503 {"WEDelete", (PyCFunction)wasteObj_WEDelete, 1,
1504 "() -> None"},
1505 {"WESetStyle", (PyCFunction)wasteObj_WESetStyle, 1,
1506 "(WEStyleMode mode, TextStyle ts) -> None"},
1507 {"WEUseStyleScrap", (PyCFunction)wasteObj_WEUseStyleScrap, 1,
1508 "(StScrpHandle hStyles) -> None"},
1509 {"WEUseText", (PyCFunction)wasteObj_WEUseText, 1,
1510 "(Handle hText) -> None"},
1511 {"WEUndo", (PyCFunction)wasteObj_WEUndo, 1,
1512 "() -> None"},
1513 {"WEClearUndo", (PyCFunction)wasteObj_WEClearUndo, 1,
1514 "() -> None"},
1515 {"WEGetUndoInfo", (PyCFunction)wasteObj_WEGetUndoInfo, 1,
1516 "() -> (WEActionKind _rv, Boolean redoFlag)"},
1517 {"WEIsTyping", (PyCFunction)wasteObj_WEIsTyping, 1,
1518 "() -> (Boolean _rv)"},
1519 {"WEGetModCount", (PyCFunction)wasteObj_WEGetModCount, 1,
1520 "() -> (unsigned long _rv)"},
1521 {"WEResetModCount", (PyCFunction)wasteObj_WEResetModCount, 1,
1522 "() -> None"},
1523 {"WEInsertObject", (PyCFunction)wasteObj_WEInsertObject, 1,
1524 "(FlavorType objectType, Handle objectDataHandle, Point objectSize) -> None"},
1525 {"WEGetSelectedObject", (PyCFunction)wasteObj_WEGetSelectedObject, 1,
1526 "() -> (WEObjectReference obj)"},
1527 {"WEFindNextObject", (PyCFunction)wasteObj_WEFindNextObject, 1,
1528 "(long offset) -> (long _rv, WEObjectReference obj)"},
1529 {"WEUseSoup", (PyCFunction)wasteObj_WEUseSoup, 1,
1530 "(WESoupHandle hSoup) -> None"},
1531 {"WECut", (PyCFunction)wasteObj_WECut, 1,
1532 "() -> None"},
1533 {"WECopy", (PyCFunction)wasteObj_WECopy, 1,
1534 "() -> None"},
1535 {"WEPaste", (PyCFunction)wasteObj_WEPaste, 1,
1536 "() -> None"},
1537 {"WECanPaste", (PyCFunction)wasteObj_WECanPaste, 1,
1538 "() -> (Boolean _rv)"},
1539 {"WEGetHiliteRgn", (PyCFunction)wasteObj_WEGetHiliteRgn, 1,
1540 "(long rangeStart, long rangeEnd) -> (RgnHandle _rv)"},
1541 {"WECharByte", (PyCFunction)wasteObj_WECharByte, 1,
1542 "(long offset) -> (short _rv)"},
1543 {"WECharType", (PyCFunction)wasteObj_WECharType, 1,
1544 "(long offset) -> (short _rv)"},
1545 {"WEStopInlineSession", (PyCFunction)wasteObj_WEStopInlineSession, 1,
1546 "() -> None"},
1547 {"WEFeatureFlag", (PyCFunction)wasteObj_WEFeatureFlag, 1,
1548 "(short feature, short action) -> (short _rv)"},
1549 {NULL, NULL, 0}
1550};
1551
1552PyMethodChain wasteObj_chain = { wasteObj_methods, NULL };
1553
1554static PyObject *wasteObj_getattr(self, name)
1555 wasteObject *self;
1556 char *name;
1557{
1558 return Py_FindMethodInChain(&wasteObj_chain, (PyObject *)self, name);
1559}
1560
1561#define wasteObj_setattr NULL
1562
1563PyTypeObject waste_Type = {
1564 PyObject_HEAD_INIT(&PyType_Type)
1565 0, /*ob_size*/
1566 "waste", /*tp_name*/
1567 sizeof(wasteObject), /*tp_basicsize*/
1568 0, /*tp_itemsize*/
1569 /* methods */
1570 (destructor) wasteObj_dealloc, /*tp_dealloc*/
1571 0, /*tp_print*/
1572 (getattrfunc) wasteObj_getattr, /*tp_getattr*/
1573 (setattrfunc) wasteObj_setattr, /*tp_setattr*/
1574};
1575
1576/* --------------------- End object type waste ---------------------- */
1577
1578
1579static PyObject *waste_WENew(_self, _args)
1580 PyObject *_self;
1581 PyObject *_args;
1582{
1583 PyObject *_res = NULL;
1584 OSErr _err;
1585 LongRect destRect;
1586 LongRect viewRect;
1587 unsigned long flags;
1588 WEReference we;
1589 if (!PyArg_ParseTuple(_args, "O&O&l",
1590 LongRect_Convert, &destRect,
1591 LongRect_Convert, &viewRect,
1592 &flags))
1593 return NULL;
1594 _err = WENew(&destRect,
1595 &viewRect,
1596 flags,
1597 &we);
1598 if (_err != noErr) return PyMac_Error(_err);
1599 _res = Py_BuildValue("O&",
1600 wasteObj_New, we);
1601 return _res;
1602}
1603
1604static PyObject *waste_WEInstallTSMHandlers(_self, _args)
1605 PyObject *_self;
1606 PyObject *_args;
1607{
1608 PyObject *_res = NULL;
1609 OSErr _err;
1610 if (!PyArg_ParseTuple(_args, ""))
1611 return NULL;
1612 _err = WEInstallTSMHandlers();
1613 if (_err != noErr) return PyMac_Error(_err);
1614 Py_INCREF(Py_None);
1615 _res = Py_None;
1616 return _res;
1617}
1618
1619static PyObject *waste_WERemoveTSMHandlers(_self, _args)
1620 PyObject *_self;
1621 PyObject *_args;
1622{
1623 PyObject *_res = NULL;
1624 OSErr _err;
1625 if (!PyArg_ParseTuple(_args, ""))
1626 return NULL;
1627 _err = WERemoveTSMHandlers();
1628 if (_err != noErr) return PyMac_Error(_err);
1629 Py_INCREF(Py_None);
1630 _res = Py_None;
1631 return _res;
1632}
1633
1634static PyObject *waste_WELongPointToPoint(_self, _args)
1635 PyObject *_self;
1636 PyObject *_args;
1637{
1638 PyObject *_res = NULL;
1639 LongPt lp;
1640 Point p;
1641 if (!PyArg_ParseTuple(_args, "O&",
1642 LongPt_Convert, &lp))
1643 return NULL;
1644 WELongPointToPoint(&lp,
1645 &p);
1646 _res = Py_BuildValue("O&",
1647 PyMac_BuildPoint, p);
1648 return _res;
1649}
1650
1651static PyObject *waste_WEPointToLongPoint(_self, _args)
1652 PyObject *_self;
1653 PyObject *_args;
1654{
1655 PyObject *_res = NULL;
1656 Point p;
1657 LongPt lp;
1658 if (!PyArg_ParseTuple(_args, "O&",
1659 PyMac_GetPoint, &p))
1660 return NULL;
1661 WEPointToLongPoint(p,
1662 &lp);
1663 _res = Py_BuildValue("O&",
1664 LongPt_New, &lp);
1665 return _res;
1666}
1667
1668static PyObject *waste_WESetLongRect(_self, _args)
1669 PyObject *_self;
1670 PyObject *_args;
1671{
1672 PyObject *_res = NULL;
1673 LongRect lr;
1674 long left;
1675 long top;
1676 long right;
1677 long bottom;
1678 if (!PyArg_ParseTuple(_args, "llll",
1679 &left,
1680 &top,
1681 &right,
1682 &bottom))
1683 return NULL;
1684 WESetLongRect(&lr,
1685 left,
1686 top,
1687 right,
1688 bottom);
1689 _res = Py_BuildValue("O&",
1690 LongRect_New, &lr);
1691 return _res;
1692}
1693
1694static PyObject *waste_WELongRectToRect(_self, _args)
1695 PyObject *_self;
1696 PyObject *_args;
1697{
1698 PyObject *_res = NULL;
1699 LongRect lr;
1700 Rect r;
1701 if (!PyArg_ParseTuple(_args, "O&",
1702 LongRect_Convert, &lr))
1703 return NULL;
1704 WELongRectToRect(&lr,
1705 &r);
1706 _res = Py_BuildValue("O&",
1707 PyMac_BuildRect, &r);
1708 return _res;
1709}
1710
1711static PyObject *waste_WERectToLongRect(_self, _args)
1712 PyObject *_self;
1713 PyObject *_args;
1714{
1715 PyObject *_res = NULL;
1716 Rect r;
1717 LongRect lr;
1718 if (!PyArg_ParseTuple(_args, "O&",
1719 PyMac_GetRect, &r))
1720 return NULL;
1721 WERectToLongRect(&r,
1722 &lr);
1723 _res = Py_BuildValue("O&",
1724 LongRect_New, &lr);
1725 return _res;
1726}
1727
1728static PyObject *waste_WEOffsetLongRect(_self, _args)
1729 PyObject *_self;
1730 PyObject *_args;
1731{
1732 PyObject *_res = NULL;
1733 LongRect lr;
1734 long hOffset;
1735 long vOffset;
1736 if (!PyArg_ParseTuple(_args, "ll",
1737 &hOffset,
1738 &vOffset))
1739 return NULL;
1740 WEOffsetLongRect(&lr,
1741 hOffset,
1742 vOffset);
1743 _res = Py_BuildValue("O&",
1744 LongRect_New, &lr);
1745 return _res;
1746}
1747
1748static PyObject *waste_WELongPointInLongRect(_self, _args)
1749 PyObject *_self;
1750 PyObject *_args;
1751{
1752 PyObject *_res = NULL;
1753 Boolean _rv;
1754 LongPt lp;
1755 LongRect lr;
1756 if (!PyArg_ParseTuple(_args, "O&O&",
1757 LongPt_Convert, &lp,
1758 LongRect_Convert, &lr))
1759 return NULL;
1760 _rv = WELongPointInLongRect(&lp,
1761 &lr);
1762 _res = Py_BuildValue("b",
1763 _rv);
1764 return _res;
1765}
1766
Jack Jansen756522f1996-05-07 15:24:01 +00001767static PyObject *waste_STDObjectHandlers(_self, _args)
1768 PyObject *_self;
1769 PyObject *_args;
1770{
1771 PyObject *_res = NULL;
1772
1773 OSErr err;
1774 // install the sample object handlers for pictures and sounds
1775#define kTypePicture 'PICT'
1776#define kTypeSound 'snd '
1777
1778 if ( !PyArg_ParseTuple(_args, "") ) return NULL;
1779
1780 if ((err = WEInstallObjectHandler(kTypePicture, weNewHandler,
1781 (UniversalProcPtr) NewWENewObjectProc(HandleNewPicture), NULL)) != noErr)
1782 goto cleanup;
1783
1784 if ((err = WEInstallObjectHandler(kTypePicture, weDisposeHandler,
1785 (UniversalProcPtr) NewWEDisposeObjectProc(HandleDisposePicture), NULL)) != noErr)
1786 goto cleanup;
1787
1788 if ((err = WEInstallObjectHandler(kTypePicture, weDrawHandler,
1789 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawPicture), NULL)) != noErr)
1790 goto cleanup;
1791
1792 if ((err = WEInstallObjectHandler(kTypeSound, weNewHandler,
1793 (UniversalProcPtr) NewWENewObjectProc(HandleNewSound), NULL)) != noErr)
1794 goto cleanup;
1795
1796 if ((err = WEInstallObjectHandler(kTypeSound, weDrawHandler,
1797 (UniversalProcPtr) NewWEDrawObjectProc(HandleDrawSound), NULL)) != noErr)
1798 goto cleanup;
1799
1800 if ((err = WEInstallObjectHandler(kTypeSound, weClickHandler,
1801 (UniversalProcPtr) NewWEClickObjectProc(HandleClickSound), NULL)) != noErr)
1802 goto cleanup;
1803 Py_INCREF(Py_None);
1804 return Py_None;
1805
1806 cleanup:
1807 return PyMac_Error(err);
1808
1809}
1810
1811static PyObject *waste_WEInstallObjectHandler(_self, _args)
1812 PyObject *_self;
1813 PyObject *_args;
1814{
1815 PyObject *_res = NULL;
1816
1817 OSErr err;
1818 FlavorType objectType;
1819 WESelector selector;
1820 PyObject *py_handler;
1821 UniversalProcPtr handler;
1822 WEReference we = NULL;
1823 PyObject *key;
1824
1825
1826 if ( !PyArg_ParseTuple(_args, "O&O&O|O&",
1827 PyMac_GetOSType, &objectType,
1828 PyMac_GetOSType, &selector,
1829 &py_handler,
1830 ExistingwasteObj_New, &we) ) return NULL;
1831
Jack Jansen25241d91996-05-20 11:30:45 +00001832 if ( selector == weNewHandler ) handler = (UniversalProcPtr)upp_new_handler;
1833 else if ( selector == weDisposeHandler ) handler = (UniversalProcPtr)upp_dispose_handler;
1834 else if ( selector == weDrawHandler ) handler = (UniversalProcPtr)upp_draw_handler;
1835 else if ( selector == weClickHandler ) handler = (UniversalProcPtr)upp_click_handler;
Jack Jansen756522f1996-05-07 15:24:01 +00001836 else return PyMac_Error(weUndefinedSelectorErr);
1837
1838 if ((key = Py_BuildValue("O&O&",
1839 PyMac_BuildOSType, objectType,
1840 PyMac_BuildOSType, selector)) == NULL )
1841 return NULL;
1842
1843 PyDict_SetItem(callbackdict, key, py_handler);
1844
1845 err = WEInstallObjectHandler(objectType, selector, handler, we);
1846 if ( err ) return PyMac_Error(err);
1847 Py_INCREF(Py_None);
1848 return Py_None;
1849
1850}
1851
Jack Jansen90ecdf41996-04-16 14:29:15 +00001852static PyMethodDef waste_methods[] = {
1853 {"WENew", (PyCFunction)waste_WENew, 1,
1854 "(LongRect destRect, LongRect viewRect, unsigned long flags) -> (WEReference we)"},
1855 {"WEInstallTSMHandlers", (PyCFunction)waste_WEInstallTSMHandlers, 1,
1856 "() -> None"},
1857 {"WERemoveTSMHandlers", (PyCFunction)waste_WERemoveTSMHandlers, 1,
1858 "() -> None"},
1859 {"WELongPointToPoint", (PyCFunction)waste_WELongPointToPoint, 1,
1860 "(LongPt lp) -> (Point p)"},
1861 {"WEPointToLongPoint", (PyCFunction)waste_WEPointToLongPoint, 1,
1862 "(Point p) -> (LongPt lp)"},
1863 {"WESetLongRect", (PyCFunction)waste_WESetLongRect, 1,
1864 "(long left, long top, long right, long bottom) -> (LongRect lr)"},
1865 {"WELongRectToRect", (PyCFunction)waste_WELongRectToRect, 1,
1866 "(LongRect lr) -> (Rect r)"},
1867 {"WERectToLongRect", (PyCFunction)waste_WERectToLongRect, 1,
1868 "(Rect r) -> (LongRect lr)"},
1869 {"WEOffsetLongRect", (PyCFunction)waste_WEOffsetLongRect, 1,
1870 "(long hOffset, long vOffset) -> (LongRect lr)"},
1871 {"WELongPointInLongRect", (PyCFunction)waste_WELongPointInLongRect, 1,
1872 "(LongPt lp, LongRect lr) -> (Boolean _rv)"},
Jack Jansen756522f1996-05-07 15:24:01 +00001873 {"STDObjectHandlers", (PyCFunction)waste_STDObjectHandlers, 1,
1874 NULL},
1875 {"WEInstallObjectHandler", (PyCFunction)waste_WEInstallObjectHandler, 1,
1876 NULL},
Jack Jansen90ecdf41996-04-16 14:29:15 +00001877 {NULL, NULL, 0}
1878};
1879
1880
1881
Jack Jansen756522f1996-05-07 15:24:01 +00001882/* Return the object corresponding to the window, or NULL */
1883
1884PyObject *
1885ExistingwasteObj_New(w)
1886 WEReference w;
1887{
1888 PyObject *it = NULL;
1889
1890 if (w == NULL)
1891 it = NULL;
1892 else
1893 WEGetInfo(weRefCon, (void *)&it, w);
1894 if (it == NULL || ((wasteObject *)it)->ob_itself != w)
1895 it = Py_None;
1896 Py_INCREF(it);
1897 return it;
1898}
1899
Jack Jansen90ecdf41996-04-16 14:29:15 +00001900
1901void initwaste()
1902{
1903 PyObject *m;
1904 PyObject *d;
1905
1906
1907
1908
1909 m = Py_InitModule("waste", waste_methods);
1910 d = PyModule_GetDict(m);
1911 waste_Error = PyMac_GetOSErrException();
1912 if (waste_Error == NULL ||
1913 PyDict_SetItemString(d, "Error", waste_Error) != 0)
1914 Py_FatalError("can't initialize waste.Error");
Jack Jansen756522f1996-05-07 15:24:01 +00001915
1916 callbackdict = PyDict_New();
1917 if (callbackdict == NULL || PyDict_SetItemString(d, "callbacks", callbackdict) != 0)
1918 Py_FatalError("can't initialize Waste.callbackdict");
1919 upp_new_handler = NewWENewObjectProc(my_new_handler);
Jack Jansen25241d91996-05-20 11:30:45 +00001920 upp_dispose_handler = NewWEDisposeObjectProc(my_dispose_handler);
1921 upp_draw_handler = NewWEDrawObjectProc(my_draw_handler);
1922 upp_click_handler = NewWEClickObjectProc(my_click_handler);
Jack Jansen756522f1996-05-07 15:24:01 +00001923
1924
Jack Jansen90ecdf41996-04-16 14:29:15 +00001925}
1926
1927/* ======================== End module waste ======================== */
1928