Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 1 | |
| 2 | /* =========================== Module TE ============================ */ |
| 3 | |
| 4 | #include "Python.h" |
| 5 | |
| 6 | |
| 7 | |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 8 | #include "macglue.h" |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 9 | #include "pymactoolbox.h" |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 10 | |
| 11 | #include <TextEdit.h> |
| 12 | |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 13 | #define as_TE(h) ((TEHandle)h) |
Jack Jansen | deb6373 | 2000-03-22 15:35:24 +0000 | [diff] [blame] | 14 | #define as_Resource(teh) ((Handle)teh) |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 15 | |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 16 | /* |
| 17 | ** Parse/generate TextStyle records |
| 18 | */ |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 19 | static PyObject * |
| 20 | TextStyle_New(itself) |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 21 | TextStylePtr itself; |
| 22 | { |
| 23 | |
| 24 | return Py_BuildValue("lllO&", (long)itself->tsFont, (long)itself->tsFace, (long)itself->tsSize, QdRGB_New, |
| 25 | &itself->tsColor); |
| 26 | } |
| 27 | |
Jack Jansen | 9d8b96c | 2000-07-14 22:16:45 +0000 | [diff] [blame] | 28 | static int |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 29 | TextStyle_Convert(v, p_itself) |
| 30 | PyObject *v; |
| 31 | TextStylePtr p_itself; |
| 32 | { |
| 33 | long font, face, size; |
| 34 | |
| 35 | if( !PyArg_ParseTuple(v, "lllO&", &font, &face, &size, QdRGB_Convert, &p_itself->tsColor) ) |
| 36 | return 0; |
| 37 | p_itself->tsFont = (short)font; |
| 38 | p_itself->tsFace = (Style)face; |
| 39 | p_itself->tsSize = (short)size; |
| 40 | return 1; |
| 41 | } |
| 42 | |
| 43 | static PyObject *TE_Error; |
| 44 | |
| 45 | /* ------------------------- Object type TE ------------------------- */ |
| 46 | |
| 47 | PyTypeObject TE_Type; |
| 48 | |
| 49 | #define TEObj_Check(x) ((x)->ob_type == &TE_Type) |
| 50 | |
| 51 | typedef struct TEObject { |
| 52 | PyObject_HEAD |
| 53 | TEHandle ob_itself; |
| 54 | } TEObject; |
| 55 | |
| 56 | PyObject *TEObj_New(itself) |
| 57 | TEHandle itself; |
| 58 | { |
| 59 | TEObject *it; |
| 60 | if (itself == NULL) { |
| 61 | PyErr_SetString(TE_Error,"Cannot create null TE"); |
| 62 | return NULL; |
| 63 | } |
| 64 | it = PyObject_NEW(TEObject, &TE_Type); |
| 65 | if (it == NULL) return NULL; |
| 66 | it->ob_itself = itself; |
| 67 | return (PyObject *)it; |
| 68 | } |
| 69 | TEObj_Convert(v, p_itself) |
| 70 | PyObject *v; |
| 71 | TEHandle *p_itself; |
| 72 | { |
| 73 | if (!TEObj_Check(v)) |
| 74 | { |
| 75 | PyErr_SetString(PyExc_TypeError, "TE required"); |
| 76 | return 0; |
| 77 | } |
| 78 | *p_itself = ((TEObject *)v)->ob_itself; |
| 79 | return 1; |
| 80 | } |
| 81 | |
| 82 | static void TEObj_dealloc(self) |
| 83 | TEObject *self; |
| 84 | { |
| 85 | TEDispose(self->ob_itself); |
| 86 | PyMem_DEL(self); |
| 87 | } |
| 88 | |
| 89 | static PyObject *TEObj_TESetText(_self, _args) |
| 90 | TEObject *_self; |
| 91 | PyObject *_args; |
| 92 | { |
| 93 | PyObject *_res = NULL; |
| 94 | char *text__in__; |
| 95 | long text__len__; |
| 96 | int text__in_len__; |
| 97 | if (!PyArg_ParseTuple(_args, "s#", |
| 98 | &text__in__, &text__in_len__)) |
| 99 | return NULL; |
| 100 | text__len__ = text__in_len__; |
| 101 | TESetText(text__in__, text__len__, |
| 102 | _self->ob_itself); |
| 103 | Py_INCREF(Py_None); |
| 104 | _res = Py_None; |
| 105 | text__error__: ; |
| 106 | return _res; |
| 107 | } |
| 108 | |
| 109 | static PyObject *TEObj_TEGetText(_self, _args) |
| 110 | TEObject *_self; |
| 111 | PyObject *_args; |
| 112 | { |
| 113 | PyObject *_res = NULL; |
| 114 | CharsHandle _rv; |
| 115 | if (!PyArg_ParseTuple(_args, "")) |
| 116 | return NULL; |
| 117 | _rv = TEGetText(_self->ob_itself); |
| 118 | _res = Py_BuildValue("O&", |
| 119 | ResObj_New, _rv); |
| 120 | return _res; |
| 121 | } |
| 122 | |
| 123 | static PyObject *TEObj_TEIdle(_self, _args) |
| 124 | TEObject *_self; |
| 125 | PyObject *_args; |
| 126 | { |
| 127 | PyObject *_res = NULL; |
| 128 | if (!PyArg_ParseTuple(_args, "")) |
| 129 | return NULL; |
| 130 | TEIdle(_self->ob_itself); |
| 131 | Py_INCREF(Py_None); |
| 132 | _res = Py_None; |
| 133 | return _res; |
| 134 | } |
| 135 | |
| 136 | static PyObject *TEObj_TESetSelect(_self, _args) |
| 137 | TEObject *_self; |
| 138 | PyObject *_args; |
| 139 | { |
| 140 | PyObject *_res = NULL; |
| 141 | long selStart; |
| 142 | long selEnd; |
| 143 | if (!PyArg_ParseTuple(_args, "ll", |
| 144 | &selStart, |
| 145 | &selEnd)) |
| 146 | return NULL; |
| 147 | TESetSelect(selStart, |
| 148 | selEnd, |
| 149 | _self->ob_itself); |
| 150 | Py_INCREF(Py_None); |
| 151 | _res = Py_None; |
| 152 | return _res; |
| 153 | } |
| 154 | |
| 155 | static PyObject *TEObj_TEActivate(_self, _args) |
| 156 | TEObject *_self; |
| 157 | PyObject *_args; |
| 158 | { |
| 159 | PyObject *_res = NULL; |
| 160 | if (!PyArg_ParseTuple(_args, "")) |
| 161 | return NULL; |
| 162 | TEActivate(_self->ob_itself); |
| 163 | Py_INCREF(Py_None); |
| 164 | _res = Py_None; |
| 165 | return _res; |
| 166 | } |
| 167 | |
| 168 | static PyObject *TEObj_TEDeactivate(_self, _args) |
| 169 | TEObject *_self; |
| 170 | PyObject *_args; |
| 171 | { |
| 172 | PyObject *_res = NULL; |
| 173 | if (!PyArg_ParseTuple(_args, "")) |
| 174 | return NULL; |
| 175 | TEDeactivate(_self->ob_itself); |
| 176 | Py_INCREF(Py_None); |
| 177 | _res = Py_None; |
| 178 | return _res; |
| 179 | } |
| 180 | |
| 181 | static PyObject *TEObj_TEKey(_self, _args) |
| 182 | TEObject *_self; |
| 183 | PyObject *_args; |
| 184 | { |
| 185 | PyObject *_res = NULL; |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 186 | CharParameter key; |
Jack Jansen | 0c4d947 | 1998-04-17 14:07:56 +0000 | [diff] [blame] | 187 | if (!PyArg_ParseTuple(_args, "h", |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 188 | &key)) |
| 189 | return NULL; |
| 190 | TEKey(key, |
| 191 | _self->ob_itself); |
| 192 | Py_INCREF(Py_None); |
| 193 | _res = Py_None; |
| 194 | return _res; |
| 195 | } |
| 196 | |
| 197 | static PyObject *TEObj_TECut(_self, _args) |
| 198 | TEObject *_self; |
| 199 | PyObject *_args; |
| 200 | { |
| 201 | PyObject *_res = NULL; |
| 202 | if (!PyArg_ParseTuple(_args, "")) |
| 203 | return NULL; |
| 204 | TECut(_self->ob_itself); |
| 205 | Py_INCREF(Py_None); |
| 206 | _res = Py_None; |
| 207 | return _res; |
| 208 | } |
| 209 | |
| 210 | static PyObject *TEObj_TECopy(_self, _args) |
| 211 | TEObject *_self; |
| 212 | PyObject *_args; |
| 213 | { |
| 214 | PyObject *_res = NULL; |
| 215 | if (!PyArg_ParseTuple(_args, "")) |
| 216 | return NULL; |
| 217 | TECopy(_self->ob_itself); |
| 218 | Py_INCREF(Py_None); |
| 219 | _res = Py_None; |
| 220 | return _res; |
| 221 | } |
| 222 | |
| 223 | static PyObject *TEObj_TEPaste(_self, _args) |
| 224 | TEObject *_self; |
| 225 | PyObject *_args; |
| 226 | { |
| 227 | PyObject *_res = NULL; |
| 228 | if (!PyArg_ParseTuple(_args, "")) |
| 229 | return NULL; |
| 230 | TEPaste(_self->ob_itself); |
| 231 | Py_INCREF(Py_None); |
| 232 | _res = Py_None; |
| 233 | return _res; |
| 234 | } |
| 235 | |
| 236 | static PyObject *TEObj_TEDelete(_self, _args) |
| 237 | TEObject *_self; |
| 238 | PyObject *_args; |
| 239 | { |
| 240 | PyObject *_res = NULL; |
| 241 | if (!PyArg_ParseTuple(_args, "")) |
| 242 | return NULL; |
| 243 | TEDelete(_self->ob_itself); |
| 244 | Py_INCREF(Py_None); |
| 245 | _res = Py_None; |
| 246 | return _res; |
| 247 | } |
| 248 | |
| 249 | static PyObject *TEObj_TEInsert(_self, _args) |
| 250 | TEObject *_self; |
| 251 | PyObject *_args; |
| 252 | { |
| 253 | PyObject *_res = NULL; |
| 254 | char *text__in__; |
| 255 | long text__len__; |
| 256 | int text__in_len__; |
| 257 | if (!PyArg_ParseTuple(_args, "s#", |
| 258 | &text__in__, &text__in_len__)) |
| 259 | return NULL; |
| 260 | text__len__ = text__in_len__; |
| 261 | TEInsert(text__in__, text__len__, |
| 262 | _self->ob_itself); |
| 263 | Py_INCREF(Py_None); |
| 264 | _res = Py_None; |
| 265 | text__error__: ; |
| 266 | return _res; |
| 267 | } |
| 268 | |
| 269 | static PyObject *TEObj_TESetAlignment(_self, _args) |
| 270 | TEObject *_self; |
| 271 | PyObject *_args; |
| 272 | { |
| 273 | PyObject *_res = NULL; |
| 274 | short just; |
| 275 | if (!PyArg_ParseTuple(_args, "h", |
| 276 | &just)) |
| 277 | return NULL; |
| 278 | TESetAlignment(just, |
| 279 | _self->ob_itself); |
| 280 | Py_INCREF(Py_None); |
| 281 | _res = Py_None; |
| 282 | return _res; |
| 283 | } |
| 284 | |
| 285 | static PyObject *TEObj_TEUpdate(_self, _args) |
| 286 | TEObject *_self; |
| 287 | PyObject *_args; |
| 288 | { |
| 289 | PyObject *_res = NULL; |
| 290 | Rect rUpdate; |
| 291 | if (!PyArg_ParseTuple(_args, "O&", |
| 292 | PyMac_GetRect, &rUpdate)) |
| 293 | return NULL; |
| 294 | TEUpdate(&rUpdate, |
| 295 | _self->ob_itself); |
| 296 | Py_INCREF(Py_None); |
| 297 | _res = Py_None; |
| 298 | return _res; |
| 299 | } |
| 300 | |
| 301 | static PyObject *TEObj_TEScroll(_self, _args) |
| 302 | TEObject *_self; |
| 303 | PyObject *_args; |
| 304 | { |
| 305 | PyObject *_res = NULL; |
| 306 | short dh; |
| 307 | short dv; |
| 308 | if (!PyArg_ParseTuple(_args, "hh", |
| 309 | &dh, |
| 310 | &dv)) |
| 311 | return NULL; |
| 312 | TEScroll(dh, |
| 313 | dv, |
| 314 | _self->ob_itself); |
| 315 | Py_INCREF(Py_None); |
| 316 | _res = Py_None; |
| 317 | return _res; |
| 318 | } |
| 319 | |
| 320 | static PyObject *TEObj_TESelView(_self, _args) |
| 321 | TEObject *_self; |
| 322 | PyObject *_args; |
| 323 | { |
| 324 | PyObject *_res = NULL; |
| 325 | if (!PyArg_ParseTuple(_args, "")) |
| 326 | return NULL; |
| 327 | TESelView(_self->ob_itself); |
| 328 | Py_INCREF(Py_None); |
| 329 | _res = Py_None; |
| 330 | return _res; |
| 331 | } |
| 332 | |
| 333 | static PyObject *TEObj_TEPinScroll(_self, _args) |
| 334 | TEObject *_self; |
| 335 | PyObject *_args; |
| 336 | { |
| 337 | PyObject *_res = NULL; |
| 338 | short dh; |
| 339 | short dv; |
| 340 | if (!PyArg_ParseTuple(_args, "hh", |
| 341 | &dh, |
| 342 | &dv)) |
| 343 | return NULL; |
| 344 | TEPinScroll(dh, |
| 345 | dv, |
| 346 | _self->ob_itself); |
| 347 | Py_INCREF(Py_None); |
| 348 | _res = Py_None; |
| 349 | return _res; |
| 350 | } |
| 351 | |
| 352 | static PyObject *TEObj_TEAutoView(_self, _args) |
| 353 | TEObject *_self; |
| 354 | PyObject *_args; |
| 355 | { |
| 356 | PyObject *_res = NULL; |
| 357 | Boolean fAuto; |
| 358 | if (!PyArg_ParseTuple(_args, "b", |
| 359 | &fAuto)) |
| 360 | return NULL; |
| 361 | TEAutoView(fAuto, |
| 362 | _self->ob_itself); |
| 363 | Py_INCREF(Py_None); |
| 364 | _res = Py_None; |
| 365 | return _res; |
| 366 | } |
| 367 | |
| 368 | static PyObject *TEObj_TECalText(_self, _args) |
| 369 | TEObject *_self; |
| 370 | PyObject *_args; |
| 371 | { |
| 372 | PyObject *_res = NULL; |
| 373 | if (!PyArg_ParseTuple(_args, "")) |
| 374 | return NULL; |
| 375 | TECalText(_self->ob_itself); |
| 376 | Py_INCREF(Py_None); |
| 377 | _res = Py_None; |
| 378 | return _res; |
| 379 | } |
| 380 | |
| 381 | static PyObject *TEObj_TEGetOffset(_self, _args) |
| 382 | TEObject *_self; |
| 383 | PyObject *_args; |
| 384 | { |
| 385 | PyObject *_res = NULL; |
| 386 | short _rv; |
| 387 | Point pt; |
| 388 | if (!PyArg_ParseTuple(_args, "O&", |
| 389 | PyMac_GetPoint, &pt)) |
| 390 | return NULL; |
| 391 | _rv = TEGetOffset(pt, |
| 392 | _self->ob_itself); |
| 393 | _res = Py_BuildValue("h", |
| 394 | _rv); |
| 395 | return _res; |
| 396 | } |
| 397 | |
| 398 | static PyObject *TEObj_TEGetPoint(_self, _args) |
| 399 | TEObject *_self; |
| 400 | PyObject *_args; |
| 401 | { |
| 402 | PyObject *_res = NULL; |
| 403 | Point _rv; |
| 404 | short offset; |
| 405 | if (!PyArg_ParseTuple(_args, "h", |
| 406 | &offset)) |
| 407 | return NULL; |
| 408 | _rv = TEGetPoint(offset, |
| 409 | _self->ob_itself); |
| 410 | _res = Py_BuildValue("O&", |
| 411 | PyMac_BuildPoint, _rv); |
| 412 | return _res; |
| 413 | } |
| 414 | |
| 415 | static PyObject *TEObj_TEClick(_self, _args) |
| 416 | TEObject *_self; |
| 417 | PyObject *_args; |
| 418 | { |
| 419 | PyObject *_res = NULL; |
| 420 | Point pt; |
| 421 | Boolean fExtend; |
| 422 | if (!PyArg_ParseTuple(_args, "O&b", |
| 423 | PyMac_GetPoint, &pt, |
| 424 | &fExtend)) |
| 425 | return NULL; |
| 426 | TEClick(pt, |
| 427 | fExtend, |
| 428 | _self->ob_itself); |
| 429 | Py_INCREF(Py_None); |
| 430 | _res = Py_None; |
| 431 | return _res; |
| 432 | } |
| 433 | |
| 434 | static PyObject *TEObj_TESetStyleHandle(_self, _args) |
| 435 | TEObject *_self; |
| 436 | PyObject *_args; |
| 437 | { |
| 438 | PyObject *_res = NULL; |
| 439 | TEStyleHandle theHandle; |
| 440 | if (!PyArg_ParseTuple(_args, "O&", |
| 441 | ResObj_Convert, &theHandle)) |
| 442 | return NULL; |
| 443 | TESetStyleHandle(theHandle, |
| 444 | _self->ob_itself); |
| 445 | Py_INCREF(Py_None); |
| 446 | _res = Py_None; |
| 447 | return _res; |
| 448 | } |
| 449 | |
| 450 | static PyObject *TEObj_TEGetStyleHandle(_self, _args) |
| 451 | TEObject *_self; |
| 452 | PyObject *_args; |
| 453 | { |
| 454 | PyObject *_res = NULL; |
| 455 | TEStyleHandle _rv; |
| 456 | if (!PyArg_ParseTuple(_args, "")) |
| 457 | return NULL; |
| 458 | _rv = TEGetStyleHandle(_self->ob_itself); |
| 459 | _res = Py_BuildValue("O&", |
| 460 | ResObj_New, _rv); |
| 461 | return _res; |
| 462 | } |
| 463 | |
| 464 | static PyObject *TEObj_TEGetStyle(_self, _args) |
| 465 | TEObject *_self; |
| 466 | PyObject *_args; |
| 467 | { |
| 468 | PyObject *_res = NULL; |
| 469 | short offset; |
| 470 | TextStyle theStyle; |
| 471 | short lineHeight; |
| 472 | short fontAscent; |
| 473 | if (!PyArg_ParseTuple(_args, "h", |
| 474 | &offset)) |
| 475 | return NULL; |
| 476 | TEGetStyle(offset, |
| 477 | &theStyle, |
| 478 | &lineHeight, |
| 479 | &fontAscent, |
| 480 | _self->ob_itself); |
| 481 | _res = Py_BuildValue("O&hh", |
| 482 | TextStyle_New, &theStyle, |
| 483 | lineHeight, |
| 484 | fontAscent); |
| 485 | return _res; |
| 486 | } |
| 487 | |
| 488 | static PyObject *TEObj_TEStylePaste(_self, _args) |
| 489 | TEObject *_self; |
| 490 | PyObject *_args; |
| 491 | { |
| 492 | PyObject *_res = NULL; |
| 493 | if (!PyArg_ParseTuple(_args, "")) |
| 494 | return NULL; |
| 495 | TEStylePaste(_self->ob_itself); |
| 496 | Py_INCREF(Py_None); |
| 497 | _res = Py_None; |
| 498 | return _res; |
| 499 | } |
| 500 | |
| 501 | static PyObject *TEObj_TESetStyle(_self, _args) |
| 502 | TEObject *_self; |
| 503 | PyObject *_args; |
| 504 | { |
| 505 | PyObject *_res = NULL; |
| 506 | short mode; |
| 507 | TextStyle newStyle; |
| 508 | Boolean fRedraw; |
| 509 | if (!PyArg_ParseTuple(_args, "hO&b", |
| 510 | &mode, |
| 511 | TextStyle_Convert, &newStyle, |
| 512 | &fRedraw)) |
| 513 | return NULL; |
| 514 | TESetStyle(mode, |
| 515 | &newStyle, |
| 516 | fRedraw, |
| 517 | _self->ob_itself); |
| 518 | Py_INCREF(Py_None); |
| 519 | _res = Py_None; |
| 520 | return _res; |
| 521 | } |
| 522 | |
| 523 | static PyObject *TEObj_TEReplaceStyle(_self, _args) |
| 524 | TEObject *_self; |
| 525 | PyObject *_args; |
| 526 | { |
| 527 | PyObject *_res = NULL; |
| 528 | short mode; |
| 529 | TextStyle oldStyle; |
| 530 | TextStyle newStyle; |
| 531 | Boolean fRedraw; |
| 532 | if (!PyArg_ParseTuple(_args, "hO&O&b", |
| 533 | &mode, |
| 534 | TextStyle_Convert, &oldStyle, |
| 535 | TextStyle_Convert, &newStyle, |
| 536 | &fRedraw)) |
| 537 | return NULL; |
| 538 | TEReplaceStyle(mode, |
| 539 | &oldStyle, |
| 540 | &newStyle, |
| 541 | fRedraw, |
| 542 | _self->ob_itself); |
| 543 | Py_INCREF(Py_None); |
| 544 | _res = Py_None; |
| 545 | return _res; |
| 546 | } |
| 547 | |
| 548 | static PyObject *TEObj_TEGetStyleScrapHandle(_self, _args) |
| 549 | TEObject *_self; |
| 550 | PyObject *_args; |
| 551 | { |
| 552 | PyObject *_res = NULL; |
| 553 | StScrpHandle _rv; |
| 554 | if (!PyArg_ParseTuple(_args, "")) |
| 555 | return NULL; |
| 556 | _rv = TEGetStyleScrapHandle(_self->ob_itself); |
| 557 | _res = Py_BuildValue("O&", |
| 558 | ResObj_New, _rv); |
| 559 | return _res; |
| 560 | } |
| 561 | |
| 562 | static PyObject *TEObj_TEStyleInsert(_self, _args) |
| 563 | TEObject *_self; |
| 564 | PyObject *_args; |
| 565 | { |
| 566 | PyObject *_res = NULL; |
| 567 | char *text__in__; |
| 568 | long text__len__; |
| 569 | int text__in_len__; |
| 570 | StScrpHandle hST; |
| 571 | if (!PyArg_ParseTuple(_args, "s#O&", |
| 572 | &text__in__, &text__in_len__, |
| 573 | ResObj_Convert, &hST)) |
| 574 | return NULL; |
| 575 | text__len__ = text__in_len__; |
| 576 | TEStyleInsert(text__in__, text__len__, |
| 577 | hST, |
| 578 | _self->ob_itself); |
| 579 | Py_INCREF(Py_None); |
| 580 | _res = Py_None; |
| 581 | text__error__: ; |
| 582 | return _res; |
| 583 | } |
| 584 | |
| 585 | static PyObject *TEObj_TEGetHeight(_self, _args) |
| 586 | TEObject *_self; |
| 587 | PyObject *_args; |
| 588 | { |
| 589 | PyObject *_res = NULL; |
| 590 | long _rv; |
| 591 | long endLine; |
| 592 | long startLine; |
| 593 | if (!PyArg_ParseTuple(_args, "ll", |
| 594 | &endLine, |
| 595 | &startLine)) |
| 596 | return NULL; |
| 597 | _rv = TEGetHeight(endLine, |
| 598 | startLine, |
| 599 | _self->ob_itself); |
| 600 | _res = Py_BuildValue("l", |
| 601 | _rv); |
| 602 | return _res; |
| 603 | } |
| 604 | |
| 605 | static PyObject *TEObj_TEContinuousStyle(_self, _args) |
| 606 | TEObject *_self; |
| 607 | PyObject *_args; |
| 608 | { |
| 609 | PyObject *_res = NULL; |
| 610 | Boolean _rv; |
| 611 | short mode; |
| 612 | TextStyle aStyle; |
| 613 | if (!PyArg_ParseTuple(_args, "hO&", |
| 614 | &mode, |
| 615 | TextStyle_Convert, &aStyle)) |
| 616 | return NULL; |
| 617 | _rv = TEContinuousStyle(&mode, |
| 618 | &aStyle, |
| 619 | _self->ob_itself); |
| 620 | _res = Py_BuildValue("bhO&", |
| 621 | _rv, |
| 622 | mode, |
| 623 | TextStyle_New, &aStyle); |
| 624 | return _res; |
| 625 | } |
| 626 | |
| 627 | static PyObject *TEObj_TEUseStyleScrap(_self, _args) |
| 628 | TEObject *_self; |
| 629 | PyObject *_args; |
| 630 | { |
| 631 | PyObject *_res = NULL; |
| 632 | long rangeStart; |
| 633 | long rangeEnd; |
| 634 | StScrpHandle newStyles; |
| 635 | Boolean fRedraw; |
| 636 | if (!PyArg_ParseTuple(_args, "llO&b", |
| 637 | &rangeStart, |
| 638 | &rangeEnd, |
| 639 | ResObj_Convert, &newStyles, |
| 640 | &fRedraw)) |
| 641 | return NULL; |
| 642 | TEUseStyleScrap(rangeStart, |
| 643 | rangeEnd, |
| 644 | newStyles, |
| 645 | fRedraw, |
| 646 | _self->ob_itself); |
| 647 | Py_INCREF(Py_None); |
| 648 | _res = Py_None; |
| 649 | return _res; |
| 650 | } |
| 651 | |
| 652 | static PyObject *TEObj_TENumStyles(_self, _args) |
| 653 | TEObject *_self; |
| 654 | PyObject *_args; |
| 655 | { |
| 656 | PyObject *_res = NULL; |
| 657 | long _rv; |
| 658 | long rangeStart; |
| 659 | long rangeEnd; |
| 660 | if (!PyArg_ParseTuple(_args, "ll", |
| 661 | &rangeStart, |
| 662 | &rangeEnd)) |
| 663 | return NULL; |
| 664 | _rv = TENumStyles(rangeStart, |
| 665 | rangeEnd, |
| 666 | _self->ob_itself); |
| 667 | _res = Py_BuildValue("l", |
| 668 | _rv); |
| 669 | return _res; |
| 670 | } |
| 671 | |
| 672 | static PyObject *TEObj_TEFeatureFlag(_self, _args) |
| 673 | TEObject *_self; |
| 674 | PyObject *_args; |
| 675 | { |
| 676 | PyObject *_res = NULL; |
| 677 | short _rv; |
| 678 | short feature; |
| 679 | short action; |
| 680 | if (!PyArg_ParseTuple(_args, "hh", |
| 681 | &feature, |
| 682 | &action)) |
| 683 | return NULL; |
| 684 | _rv = TEFeatureFlag(feature, |
| 685 | action, |
| 686 | _self->ob_itself); |
| 687 | _res = Py_BuildValue("h", |
| 688 | _rv); |
| 689 | return _res; |
| 690 | } |
| 691 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 692 | static PyObject *TEObj_TEGetHiliteRgn(_self, _args) |
| 693 | TEObject *_self; |
| 694 | PyObject *_args; |
| 695 | { |
| 696 | PyObject *_res = NULL; |
| 697 | OSErr _err; |
| 698 | RgnHandle region; |
| 699 | if (!PyArg_ParseTuple(_args, "O&", |
| 700 | ResObj_Convert, ®ion)) |
| 701 | return NULL; |
| 702 | _err = TEGetHiliteRgn(region, |
| 703 | _self->ob_itself); |
| 704 | if (_err != noErr) return PyMac_Error(_err); |
| 705 | Py_INCREF(Py_None); |
| 706 | _res = Py_None; |
| 707 | return _res; |
| 708 | } |
| 709 | |
Jack Jansen | deb6373 | 2000-03-22 15:35:24 +0000 | [diff] [blame] | 710 | static PyObject *TEObj_as_Resource(_self, _args) |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 711 | TEObject *_self; |
| 712 | PyObject *_args; |
| 713 | { |
| 714 | PyObject *_res = NULL; |
| 715 | Handle _rv; |
| 716 | if (!PyArg_ParseTuple(_args, "")) |
| 717 | return NULL; |
Jack Jansen | deb6373 | 2000-03-22 15:35:24 +0000 | [diff] [blame] | 718 | _rv = as_Resource(_self->ob_itself); |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 719 | _res = Py_BuildValue("O&", |
| 720 | ResObj_New, _rv); |
| 721 | return _res; |
| 722 | } |
| 723 | |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 724 | static PyMethodDef TEObj_methods[] = { |
| 725 | {"TESetText", (PyCFunction)TEObj_TESetText, 1, |
| 726 | "(Buffer text) -> None"}, |
| 727 | {"TEGetText", (PyCFunction)TEObj_TEGetText, 1, |
| 728 | "() -> (CharsHandle _rv)"}, |
| 729 | {"TEIdle", (PyCFunction)TEObj_TEIdle, 1, |
| 730 | "() -> None"}, |
| 731 | {"TESetSelect", (PyCFunction)TEObj_TESetSelect, 1, |
| 732 | "(long selStart, long selEnd) -> None"}, |
| 733 | {"TEActivate", (PyCFunction)TEObj_TEActivate, 1, |
| 734 | "() -> None"}, |
| 735 | {"TEDeactivate", (PyCFunction)TEObj_TEDeactivate, 1, |
| 736 | "() -> None"}, |
| 737 | {"TEKey", (PyCFunction)TEObj_TEKey, 1, |
Jack Jansen | 21f9687 | 1998-02-20 16:02:09 +0000 | [diff] [blame] | 738 | "(CharParameter key) -> None"}, |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 739 | {"TECut", (PyCFunction)TEObj_TECut, 1, |
| 740 | "() -> None"}, |
| 741 | {"TECopy", (PyCFunction)TEObj_TECopy, 1, |
| 742 | "() -> None"}, |
| 743 | {"TEPaste", (PyCFunction)TEObj_TEPaste, 1, |
| 744 | "() -> None"}, |
| 745 | {"TEDelete", (PyCFunction)TEObj_TEDelete, 1, |
| 746 | "() -> None"}, |
| 747 | {"TEInsert", (PyCFunction)TEObj_TEInsert, 1, |
| 748 | "(Buffer text) -> None"}, |
| 749 | {"TESetAlignment", (PyCFunction)TEObj_TESetAlignment, 1, |
| 750 | "(short just) -> None"}, |
| 751 | {"TEUpdate", (PyCFunction)TEObj_TEUpdate, 1, |
| 752 | "(Rect rUpdate) -> None"}, |
| 753 | {"TEScroll", (PyCFunction)TEObj_TEScroll, 1, |
| 754 | "(short dh, short dv) -> None"}, |
| 755 | {"TESelView", (PyCFunction)TEObj_TESelView, 1, |
| 756 | "() -> None"}, |
| 757 | {"TEPinScroll", (PyCFunction)TEObj_TEPinScroll, 1, |
| 758 | "(short dh, short dv) -> None"}, |
| 759 | {"TEAutoView", (PyCFunction)TEObj_TEAutoView, 1, |
| 760 | "(Boolean fAuto) -> None"}, |
| 761 | {"TECalText", (PyCFunction)TEObj_TECalText, 1, |
| 762 | "() -> None"}, |
| 763 | {"TEGetOffset", (PyCFunction)TEObj_TEGetOffset, 1, |
| 764 | "(Point pt) -> (short _rv)"}, |
| 765 | {"TEGetPoint", (PyCFunction)TEObj_TEGetPoint, 1, |
| 766 | "(short offset) -> (Point _rv)"}, |
| 767 | {"TEClick", (PyCFunction)TEObj_TEClick, 1, |
| 768 | "(Point pt, Boolean fExtend) -> None"}, |
| 769 | {"TESetStyleHandle", (PyCFunction)TEObj_TESetStyleHandle, 1, |
| 770 | "(TEStyleHandle theHandle) -> None"}, |
| 771 | {"TEGetStyleHandle", (PyCFunction)TEObj_TEGetStyleHandle, 1, |
| 772 | "() -> (TEStyleHandle _rv)"}, |
| 773 | {"TEGetStyle", (PyCFunction)TEObj_TEGetStyle, 1, |
| 774 | "(short offset) -> (TextStyle theStyle, short lineHeight, short fontAscent)"}, |
| 775 | {"TEStylePaste", (PyCFunction)TEObj_TEStylePaste, 1, |
| 776 | "() -> None"}, |
| 777 | {"TESetStyle", (PyCFunction)TEObj_TESetStyle, 1, |
| 778 | "(short mode, TextStyle newStyle, Boolean fRedraw) -> None"}, |
| 779 | {"TEReplaceStyle", (PyCFunction)TEObj_TEReplaceStyle, 1, |
| 780 | "(short mode, TextStyle oldStyle, TextStyle newStyle, Boolean fRedraw) -> None"}, |
| 781 | {"TEGetStyleScrapHandle", (PyCFunction)TEObj_TEGetStyleScrapHandle, 1, |
| 782 | "() -> (StScrpHandle _rv)"}, |
| 783 | {"TEStyleInsert", (PyCFunction)TEObj_TEStyleInsert, 1, |
| 784 | "(Buffer text, StScrpHandle hST) -> None"}, |
| 785 | {"TEGetHeight", (PyCFunction)TEObj_TEGetHeight, 1, |
| 786 | "(long endLine, long startLine) -> (long _rv)"}, |
| 787 | {"TEContinuousStyle", (PyCFunction)TEObj_TEContinuousStyle, 1, |
| 788 | "(short mode, TextStyle aStyle) -> (Boolean _rv, short mode, TextStyle aStyle)"}, |
| 789 | {"TEUseStyleScrap", (PyCFunction)TEObj_TEUseStyleScrap, 1, |
| 790 | "(long rangeStart, long rangeEnd, StScrpHandle newStyles, Boolean fRedraw) -> None"}, |
| 791 | {"TENumStyles", (PyCFunction)TEObj_TENumStyles, 1, |
| 792 | "(long rangeStart, long rangeEnd) -> (long _rv)"}, |
| 793 | {"TEFeatureFlag", (PyCFunction)TEObj_TEFeatureFlag, 1, |
| 794 | "(short feature, short action) -> (short _rv)"}, |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 795 | {"TEGetHiliteRgn", (PyCFunction)TEObj_TEGetHiliteRgn, 1, |
| 796 | "(RgnHandle region) -> None"}, |
Jack Jansen | deb6373 | 2000-03-22 15:35:24 +0000 | [diff] [blame] | 797 | {"as_Resource", (PyCFunction)TEObj_as_Resource, 1, |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 798 | "() -> (Handle _rv)"}, |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 799 | {NULL, NULL, 0} |
| 800 | }; |
| 801 | |
| 802 | PyMethodChain TEObj_chain = { TEObj_methods, NULL }; |
| 803 | |
| 804 | static PyObject *TEObj_getattr(self, name) |
| 805 | TEObject *self; |
| 806 | char *name; |
| 807 | { |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 808 | |
| 809 | if( strcmp(name, "destRect") == 0 ) |
| 810 | return Py_BuildValue("O&", PyMac_BuildRect, |
Jack Jansen | 19171a2 | 1996-04-16 14:32:01 +0000 | [diff] [blame] | 811 | &(*self->ob_itself)->destRect); |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 812 | if( strcmp(name, "viewRect") == 0 ) |
| 813 | return Py_BuildValue("O&", PyMac_BuildRect, |
Jack Jansen | 19171a2 | 1996-04-16 14:32:01 +0000 | [diff] [blame] | 814 | &(*self->ob_itself)->viewRect); |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 815 | if( strcmp(name, "selRect") == 0 ) |
| 816 | return Py_BuildValue("O&", PyMac_BuildRect, |
Jack Jansen | 19171a2 | 1996-04-16 14:32:01 +0000 | [diff] [blame] | 817 | &(*self->ob_itself)->selRect); |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 818 | if( strcmp(name, "lineHeight") == 0 ) |
| 819 | return Py_BuildValue("h", (*self->ob_itself)->lineHeight); |
| 820 | if( strcmp(name, "fontAscent") == 0 ) |
| 821 | return Py_BuildValue("h", (*self->ob_itself)->fontAscent); |
| 822 | if( strcmp(name, "selPoint") == 0 ) |
| 823 | return Py_BuildValue("O&", PyMac_BuildPoint, |
Jack Jansen | deb6373 | 2000-03-22 15:35:24 +0000 | [diff] [blame] | 824 | (*self->ob_itself)->selPoint); |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 825 | if( strcmp(name, "selStart") == 0 ) |
| 826 | return Py_BuildValue("h", (*self->ob_itself)->selStart); |
| 827 | if( strcmp(name, "selEnd") == 0 ) |
| 828 | return Py_BuildValue("h", (*self->ob_itself)->selEnd); |
| 829 | if( strcmp(name, "active") == 0 ) |
| 830 | return Py_BuildValue("h", (*self->ob_itself)->active); |
Jack Jansen | 19171a2 | 1996-04-16 14:32:01 +0000 | [diff] [blame] | 831 | if( strcmp(name, "just") == 0 ) |
| 832 | return Py_BuildValue("h", (*self->ob_itself)->just); |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 833 | if( strcmp(name, "teLength") == 0 ) |
| 834 | return Py_BuildValue("h", (*self->ob_itself)->teLength); |
Jack Jansen | 19171a2 | 1996-04-16 14:32:01 +0000 | [diff] [blame] | 835 | if( strcmp(name, "txFont") == 0 ) |
| 836 | return Py_BuildValue("h", (*self->ob_itself)->txFont); |
| 837 | if( strcmp(name, "txFace") == 0 ) |
| 838 | return Py_BuildValue("h", (*self->ob_itself)->txFace); |
| 839 | if( strcmp(name, "txMode") == 0 ) |
| 840 | return Py_BuildValue("h", (*self->ob_itself)->txMode); |
| 841 | if( strcmp(name, "txSize") == 0 ) |
| 842 | return Py_BuildValue("h", (*self->ob_itself)->txSize); |
| 843 | if( strcmp(name, "nLines") == 0 ) |
| 844 | return Py_BuildValue("h", (*self->ob_itself)->nLines); |
Jack Jansen | 46d9e79 | 1996-04-12 16:29:23 +0000 | [diff] [blame] | 845 | |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 846 | return Py_FindMethodInChain(&TEObj_chain, (PyObject *)self, name); |
| 847 | } |
| 848 | |
| 849 | #define TEObj_setattr NULL |
| 850 | |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 851 | #define TEObj_compare NULL |
| 852 | |
| 853 | #define TEObj_repr NULL |
| 854 | |
| 855 | #define TEObj_hash NULL |
| 856 | |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 857 | PyTypeObject TE_Type = { |
| 858 | PyObject_HEAD_INIT(&PyType_Type) |
| 859 | 0, /*ob_size*/ |
| 860 | "TE", /*tp_name*/ |
| 861 | sizeof(TEObject), /*tp_basicsize*/ |
| 862 | 0, /*tp_itemsize*/ |
| 863 | /* methods */ |
| 864 | (destructor) TEObj_dealloc, /*tp_dealloc*/ |
| 865 | 0, /*tp_print*/ |
| 866 | (getattrfunc) TEObj_getattr, /*tp_getattr*/ |
| 867 | (setattrfunc) TEObj_setattr, /*tp_setattr*/ |
Jack Jansen | a05ac60 | 1999-12-12 21:41:51 +0000 | [diff] [blame] | 868 | (cmpfunc) TEObj_compare, /*tp_compare*/ |
| 869 | (reprfunc) TEObj_repr, /*tp_repr*/ |
| 870 | (PyNumberMethods *)0, /* tp_as_number */ |
| 871 | (PySequenceMethods *)0, /* tp_as_sequence */ |
| 872 | (PyMappingMethods *)0, /* tp_as_mapping */ |
| 873 | (hashfunc) TEObj_hash, /*tp_hash*/ |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 874 | }; |
| 875 | |
| 876 | /* ----------------------- End object type TE ----------------------- */ |
| 877 | |
| 878 | |
| 879 | static PyObject *TE_TEScrapHandle(_self, _args) |
| 880 | PyObject *_self; |
| 881 | PyObject *_args; |
| 882 | { |
| 883 | PyObject *_res = NULL; |
| 884 | Handle _rv; |
| 885 | if (!PyArg_ParseTuple(_args, "")) |
| 886 | return NULL; |
| 887 | _rv = TEScrapHandle(); |
| 888 | _res = Py_BuildValue("O&", |
| 889 | ResObj_New, _rv); |
| 890 | return _res; |
| 891 | } |
| 892 | |
| 893 | static PyObject *TE_TEGetScrapLength(_self, _args) |
| 894 | PyObject *_self; |
| 895 | PyObject *_args; |
| 896 | { |
| 897 | PyObject *_res = NULL; |
| 898 | long _rv; |
| 899 | if (!PyArg_ParseTuple(_args, "")) |
| 900 | return NULL; |
| 901 | _rv = TEGetScrapLength(); |
| 902 | _res = Py_BuildValue("l", |
| 903 | _rv); |
| 904 | return _res; |
| 905 | } |
| 906 | |
| 907 | static PyObject *TE_TENew(_self, _args) |
| 908 | PyObject *_self; |
| 909 | PyObject *_args; |
| 910 | { |
| 911 | PyObject *_res = NULL; |
| 912 | TEHandle _rv; |
| 913 | Rect destRect; |
| 914 | Rect viewRect; |
| 915 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 916 | PyMac_GetRect, &destRect, |
| 917 | PyMac_GetRect, &viewRect)) |
| 918 | return NULL; |
| 919 | _rv = TENew(&destRect, |
| 920 | &viewRect); |
| 921 | _res = Py_BuildValue("O&", |
| 922 | TEObj_New, _rv); |
| 923 | return _res; |
| 924 | } |
| 925 | |
| 926 | static PyObject *TE_TETextBox(_self, _args) |
| 927 | PyObject *_self; |
| 928 | PyObject *_args; |
| 929 | { |
| 930 | PyObject *_res = NULL; |
| 931 | char *text__in__; |
| 932 | long text__len__; |
| 933 | int text__in_len__; |
| 934 | Rect box; |
| 935 | short just; |
| 936 | if (!PyArg_ParseTuple(_args, "s#O&h", |
| 937 | &text__in__, &text__in_len__, |
| 938 | PyMac_GetRect, &box, |
| 939 | &just)) |
| 940 | return NULL; |
| 941 | text__len__ = text__in_len__; |
| 942 | TETextBox(text__in__, text__len__, |
| 943 | &box, |
| 944 | just); |
| 945 | Py_INCREF(Py_None); |
| 946 | _res = Py_None; |
| 947 | text__error__: ; |
| 948 | return _res; |
| 949 | } |
| 950 | |
| 951 | static PyObject *TE_TEStyleNew(_self, _args) |
| 952 | PyObject *_self; |
| 953 | PyObject *_args; |
| 954 | { |
| 955 | PyObject *_res = NULL; |
| 956 | TEHandle _rv; |
| 957 | Rect destRect; |
| 958 | Rect viewRect; |
| 959 | if (!PyArg_ParseTuple(_args, "O&O&", |
| 960 | PyMac_GetRect, &destRect, |
| 961 | PyMac_GetRect, &viewRect)) |
| 962 | return NULL; |
| 963 | _rv = TEStyleNew(&destRect, |
| 964 | &viewRect); |
| 965 | _res = Py_BuildValue("O&", |
| 966 | TEObj_New, _rv); |
| 967 | return _res; |
| 968 | } |
| 969 | |
| 970 | static PyObject *TE_TESetScrapLength(_self, _args) |
| 971 | PyObject *_self; |
| 972 | PyObject *_args; |
| 973 | { |
| 974 | PyObject *_res = NULL; |
| 975 | long length; |
| 976 | if (!PyArg_ParseTuple(_args, "l", |
| 977 | &length)) |
| 978 | return NULL; |
| 979 | TESetScrapLength(length); |
| 980 | Py_INCREF(Py_None); |
| 981 | _res = Py_None; |
| 982 | return _res; |
| 983 | } |
| 984 | |
| 985 | static PyObject *TE_TEFromScrap(_self, _args) |
| 986 | PyObject *_self; |
| 987 | PyObject *_args; |
| 988 | { |
| 989 | PyObject *_res = NULL; |
| 990 | OSErr _err; |
| 991 | if (!PyArg_ParseTuple(_args, "")) |
| 992 | return NULL; |
| 993 | _err = TEFromScrap(); |
| 994 | if (_err != noErr) return PyMac_Error(_err); |
| 995 | Py_INCREF(Py_None); |
| 996 | _res = Py_None; |
| 997 | return _res; |
| 998 | } |
| 999 | |
| 1000 | static PyObject *TE_TEToScrap(_self, _args) |
| 1001 | PyObject *_self; |
| 1002 | PyObject *_args; |
| 1003 | { |
| 1004 | PyObject *_res = NULL; |
| 1005 | OSErr _err; |
| 1006 | if (!PyArg_ParseTuple(_args, "")) |
| 1007 | return NULL; |
| 1008 | _err = TEToScrap(); |
| 1009 | if (_err != noErr) return PyMac_Error(_err); |
| 1010 | Py_INCREF(Py_None); |
| 1011 | _res = Py_None; |
| 1012 | return _res; |
| 1013 | } |
| 1014 | |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame^] | 1015 | #if TARGET_API_MAC_CARBON |
| 1016 | |
| 1017 | static PyObject *TE_TEGetScrapHandle(_self, _args) |
| 1018 | PyObject *_self; |
| 1019 | PyObject *_args; |
| 1020 | { |
| 1021 | PyObject *_res = NULL; |
| 1022 | Handle _rv; |
| 1023 | if (!PyArg_ParseTuple(_args, "")) |
| 1024 | return NULL; |
| 1025 | _rv = TEGetScrapHandle(); |
| 1026 | _res = Py_BuildValue("O&", |
| 1027 | ResObj_New, _rv); |
| 1028 | return _res; |
| 1029 | } |
| 1030 | #endif |
| 1031 | |
| 1032 | #if TARGET_API_MAC_CARBON |
| 1033 | |
| 1034 | static PyObject *TE_TESetScrapHandle(_self, _args) |
| 1035 | PyObject *_self; |
| 1036 | PyObject *_args; |
| 1037 | { |
| 1038 | PyObject *_res = NULL; |
| 1039 | Handle value; |
| 1040 | if (!PyArg_ParseTuple(_args, "O&", |
| 1041 | ResObj_Convert, &value)) |
| 1042 | return NULL; |
| 1043 | TESetScrapHandle(value); |
| 1044 | Py_INCREF(Py_None); |
| 1045 | _res = Py_None; |
| 1046 | return _res; |
| 1047 | } |
| 1048 | #endif |
| 1049 | |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 1050 | static PyObject *TE_as_TE(_self, _args) |
| 1051 | PyObject *_self; |
| 1052 | PyObject *_args; |
| 1053 | { |
| 1054 | PyObject *_res = NULL; |
| 1055 | TEHandle _rv; |
| 1056 | Handle h; |
| 1057 | if (!PyArg_ParseTuple(_args, "O&", |
| 1058 | ResObj_Convert, &h)) |
| 1059 | return NULL; |
| 1060 | _rv = as_TE(h); |
| 1061 | _res = Py_BuildValue("O&", |
| 1062 | TEObj_New, _rv); |
| 1063 | return _res; |
| 1064 | } |
| 1065 | |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 1066 | static PyMethodDef TE_methods[] = { |
| 1067 | {"TEScrapHandle", (PyCFunction)TE_TEScrapHandle, 1, |
| 1068 | "() -> (Handle _rv)"}, |
| 1069 | {"TEGetScrapLength", (PyCFunction)TE_TEGetScrapLength, 1, |
| 1070 | "() -> (long _rv)"}, |
| 1071 | {"TENew", (PyCFunction)TE_TENew, 1, |
| 1072 | "(Rect destRect, Rect viewRect) -> (TEHandle _rv)"}, |
| 1073 | {"TETextBox", (PyCFunction)TE_TETextBox, 1, |
| 1074 | "(Buffer text, Rect box, short just) -> None"}, |
| 1075 | {"TEStyleNew", (PyCFunction)TE_TEStyleNew, 1, |
| 1076 | "(Rect destRect, Rect viewRect) -> (TEHandle _rv)"}, |
| 1077 | {"TESetScrapLength", (PyCFunction)TE_TESetScrapLength, 1, |
| 1078 | "(long length) -> None"}, |
| 1079 | {"TEFromScrap", (PyCFunction)TE_TEFromScrap, 1, |
| 1080 | "() -> None"}, |
| 1081 | {"TEToScrap", (PyCFunction)TE_TEToScrap, 1, |
| 1082 | "() -> None"}, |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame^] | 1083 | |
| 1084 | #if TARGET_API_MAC_CARBON |
| 1085 | {"TEGetScrapHandle", (PyCFunction)TE_TEGetScrapHandle, 1, |
| 1086 | "() -> (Handle _rv)"}, |
| 1087 | #endif |
| 1088 | |
| 1089 | #if TARGET_API_MAC_CARBON |
| 1090 | {"TESetScrapHandle", (PyCFunction)TE_TESetScrapHandle, 1, |
| 1091 | "(Handle value) -> None"}, |
| 1092 | #endif |
Jack Jansen | a1a0fef | 1999-12-23 14:32:06 +0000 | [diff] [blame] | 1093 | {"as_TE", (PyCFunction)TE_as_TE, 1, |
| 1094 | "(Handle h) -> (TEHandle _rv)"}, |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 1095 | {NULL, NULL, 0} |
| 1096 | }; |
| 1097 | |
| 1098 | |
| 1099 | |
| 1100 | |
| 1101 | void initTE() |
| 1102 | { |
| 1103 | PyObject *m; |
| 1104 | PyObject *d; |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | m = Py_InitModule("TE", TE_methods); |
| 1110 | d = PyModule_GetDict(m); |
| 1111 | TE_Error = PyMac_GetOSErrException(); |
| 1112 | if (TE_Error == NULL || |
| 1113 | PyDict_SetItemString(d, "Error", TE_Error) != 0) |
Jack Jansen | 723ad8a | 2000-12-12 22:10:21 +0000 | [diff] [blame^] | 1114 | return; |
Jack Jansen | a755e68 | 1997-09-20 17:40:22 +0000 | [diff] [blame] | 1115 | TE_Type.ob_type = &PyType_Type; |
| 1116 | Py_INCREF(&TE_Type); |
| 1117 | if (PyDict_SetItemString(d, "TEType", (PyObject *)&TE_Type) != 0) |
| 1118 | Py_FatalError("can't initialize TEType"); |
Jack Jansen | 8a452d6 | 1996-04-10 14:41:08 +0000 | [diff] [blame] | 1119 | } |
| 1120 | |
| 1121 | /* ========================= End module TE ========================== */ |
| 1122 | |