199
212
METH_NOARGS, "() - Gets font list for Text3d"},
200
213
{"setFont", ( PyCFunction ) Text3d_setFont,
201
214
METH_VARARGS, "() - Sets font for Text3d"},
215
{"addFrame", ( PyCFunction ) Text3d_addFrame,
216
METH_NOARGS, "() - adds a new text frame"},
217
{"removeFrame", ( PyCFunction ) Text3d_removeFrame,
218
METH_VARARGS, "(index) - remove this frame"},
202
219
{NULL, NULL, 0, NULL}
223
static PyObject *Text3d_getTotalFrames( BPy_Text3d * self )
225
return PyInt_FromLong( (long)(self->curve->totbox ) );
228
static PyObject *Text3d_getActiveFrame( BPy_Text3d * self )
230
return PyInt_FromLong( (long)(self->curve->actbox-1) );
233
static int Text3d_setActiveFrame( BPy_Text3d * self, PyObject * value )
235
struct Curve *curve= self->curve;
236
PyObject* frame_int = PyNumber_Int( value );
241
return EXPP_ReturnIntError( PyExc_TypeError,
242
"expected integer argument" );
244
index = ( int )PyInt_AS_LONG( frame_int );
246
if (index < 1 || index > curve->totbox)
247
return EXPP_ReturnIntError( PyExc_IndexError,
248
"index out of range" );
250
curve->actbox = index;
256
static PyObject *getFloatAttr( BPy_Text3d *self, void *type )
259
struct Curve *curve= self->curve;
261
switch( (int)type ) {
262
case EXPP_T3D_ATTR_FRAME_WIDTH:
263
param = curve->tb[curve->actbox-1].w;
265
case EXPP_T3D_ATTR_FRAME_HEIGHT:
266
param = curve->tb[curve->actbox-1].h;
268
case EXPP_T3D_ATTR_FRAME_X:
269
param = curve->tb[curve->actbox-1].x;
271
case EXPP_T3D_ATTR_FRAME_Y:
272
param = curve->tb[curve->actbox-1].y;
276
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
277
"undefined type in getFloatAttr" );
279
return PyFloat_FromDouble( param );
282
static int setFloatAttrClamp( BPy_Text3d *self, PyObject *value, void *type )
285
struct Curve *curve= self->curve;
288
switch( (int)type ) {
289
case EXPP_T3D_ATTR_FRAME_WIDTH:
292
param = &(curve->tb[curve->actbox-1].w);
294
case EXPP_T3D_ATTR_FRAME_HEIGHT:
297
param = &(curve->tb[curve->actbox-1].h);
299
case EXPP_T3D_ATTR_FRAME_X:
302
param = &(curve->tb[curve->actbox-1].x);
304
case EXPP_T3D_ATTR_FRAME_Y:
307
param = &(curve->tb[curve->actbox-1].y);
311
return EXPP_ReturnIntError( PyExc_RuntimeError,
312
"undefined type in setFloatAttrClamp" );
315
return EXPP_setFloatClamped( value, param, min, max );
318
/*****************************************************************************/
319
/* Python attributes get/set structure: */
320
/*****************************************************************************/
321
static PyGetSetDef BPy_Text3d_getseters[] = {
322
GENERIC_LIB_GETSETATTR, /* didnt have any attributes, at least lets have the standard ID attrs */
324
(getter)Text3d_getActiveFrame, (setter)Text3d_setActiveFrame,
325
"the index of the active text frame",
328
(getter)Text3d_getTotalFrames, (setter)NULL,
329
"the total number of text frames",
333
(getter)getFloatAttr, (setter)setFloatAttrClamp,
334
"the width of the active text frame",
335
(void *)EXPP_T3D_ATTR_FRAME_WIDTH},
337
(getter)getFloatAttr, (setter)setFloatAttrClamp,
338
"the height of the active text frame",
339
(void *)EXPP_T3D_ATTR_FRAME_HEIGHT},
341
(getter)getFloatAttr, (setter)setFloatAttrClamp,
342
"the X position of the active text frame",
343
(void *)EXPP_T3D_ATTR_FRAME_X},
345
(getter)getFloatAttr, (setter)setFloatAttrClamp,
346
"the Y position of the active text frame",
347
(void *)EXPP_T3D_ATTR_FRAME_Y},
348
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
205
351
/*****************************************************************************/
206
352
/* Python Text3d_Type structure definition: */
207
353
/*****************************************************************************/
212
358
sizeof( BPy_Text3d ), /* tp_basicsize */
213
359
0, /* tp_itemsize */
215
( destructor ) Text3dDeAlloc, /* tp_dealloc */
217
( getattrfunc ) Text3dGetAttr, /* tp_getattr */
218
( setattrfunc ) Text3dSetAttr, /* tp_setattr */
220
( reprfunc ) Text3dRepr, /* tp_repr */
221
0, /* tp_as_number */
222
0, /* tp_as_sequence */
223
0, /* tp_as_mapping */
228
BPy_Text3d_methods, /* tp_methods */
361
NULL, /* tp_dealloc */
363
NULL, /* tp_getattr */
364
NULL, /* tp_setattr */
365
( cmpfunc ) Text3d_compare, /* tp_compare */
366
( reprfunc ) Text3d_repr, /* tp_repr */
367
/* Method suites for standard classes */
369
NULL, /* PyNumberMethods *tp_as_number; */
370
NULL, /* PySequenceMethods *tp_as_sequence; */
371
NULL, /* PyMappingMethods *tp_as_mapping; */
373
/* More standard operations (here for binary compatibility) */
375
( hashfunc ) GenericLib_hash, /* hashfunc tp_hash; */
376
NULL, /* ternaryfunc tp_call; */
377
NULL, /* reprfunc tp_str; */
378
NULL, /* getattrofunc tp_getattro; */
379
NULL, /* setattrofunc tp_setattro; */
381
/* Functions to access object as input/output buffer */
382
NULL, /* PyBufferProcs *tp_as_buffer; */
384
/*** Flags to define presence of optional/expanded features ***/
385
Py_TPFLAGS_DEFAULT, /* long tp_flags; */
387
NULL, /* char *tp_doc; Documentation string */
388
/*** Assigned meaning in release 2.0 ***/
389
/* call function for all accessible objects */
390
NULL, /* traverseproc tp_traverse; */
392
/* delete references to contained objects */
393
NULL, /* inquiry tp_clear; */
395
/*** Assigned meaning in release 2.1 ***/
396
/*** rich comparisons ***/
397
NULL, /* richcmpfunc tp_richcompare; */
399
/*** weak reference enabler ***/
400
0, /* long tp_weaklistoffset; */
402
/*** Added in release 2.2 ***/
404
NULL, /* getiterfunc tp_iter; */
405
NULL, /* iternextfunc tp_iternext; */
407
/*** Attribute descriptor and subclassing stuff ***/
408
BPy_Text3d_methods, /* struct PyMethodDef *tp_methods; */
409
NULL, /* struct PyMemberDef *tp_members; */
410
BPy_Text3d_getseters, /* struct PyGetSetDef *tp_getset; */
411
NULL, /* struct _typeobject *tp_base; */
412
NULL, /* PyObject *tp_dict; */
413
NULL, /* descrgetfunc tp_descr_get; */
414
NULL, /* descrsetfunc tp_descr_set; */
415
0, /* long tp_dictoffset; */
416
NULL, /* initproc tp_init; */
417
NULL, /* allocfunc tp_alloc; */
418
NULL, /* newfunc tp_new; */
419
/* Low-level free-memory routine */
420
NULL, /* freefunc tp_free; */
421
/* For PyObject_IS_GC */
422
NULL, /* inquiry tp_is_gc; */
423
NULL, /* PyObject *tp_bases; */
424
/* method resolution order */
425
NULL, /* PyObject *tp_mro; */
426
NULL, /* PyObject *tp_cache; */
427
NULL, /* PyObject *tp_subclasses; */
428
NULL, /* PyObject *tp_weaklist; */
233
434
* Text3d_update( )
234
435
* method to update display list for a Curve.
395
598
return ( submodule );
398
static void Text3dDeAlloc( BPy_Text3d * self )
400
PyObject_DEL( self );
403
/*****************************************************************************/
404
/* Function: Text3dGetAttr */
405
/* Description: This is a callback function for the BPy_Text3d type. It is */
406
/* the function that accesses BPy_Text3d "member variables" and */
408
/*****************************************************************************/
409
static PyObject *Text3dGetAttr( BPy_Text3d * self, char *name )
411
return Py_FindMethod( BPy_Text3d_methods, ( PyObject * ) self, name );
414
/*****************************************************************************
415
* Function: Text3dSetAttr
416
* Description: Callback function for the BPy_Effect type to
417
* sets Text3d Data attributes (member variables).
419
****************************************************************************/
421
static int Text3dSetAttr( BPy_Text3d * self, char *name, PyObject * value )
423
return 0; /* normal exit */
427
601
/****************************************************************************
428
* Function: Text3dRepr
602
* Function: Text3d_repr
429
603
* Description: Callback function for the BPy_Text3d type to It
430
604
* build a meaninful string to represent Text3d objects.
432
606
***************************************************************************/
434
static PyObject *Text3dRepr( BPy_Text3d * self )
608
static PyObject *Text3d_repr( BPy_Text3d * self )
436
610
/* skip over CU in idname. CUTEXT */
437
611
return PyString_FromFormat( "[Text3d \"%s\"]",
438
612
self->curve->id.name + 2 );
443
int Text3d_CheckPyObject( PyObject * py_obj )
615
/****************************************************************************
616
* Function: Text3d_compare
617
* Description: Callback function for the BPy_Text3d type to Compare 2 types
619
***************************************************************************/
621
/* mat_a==mat_b or mat_a!=mat_b*/
622
static int Text3d_compare( BPy_Text3d * a, BPy_Text3d * b )
445
return ( py_obj->ob_type == &Text3d_Type );
624
return ( a->curve == b->curve) ? 0 : -1;
448
627
struct Text3d *Text3d_FromPyObject( PyObject * py_obj )
1132
static PyObject *Text3d_addFrame( BPy_Text3d * self )
1134
Curve *cu = self->curve;
1136
if (cu->totbox >= 256)
1137
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1138
"limited to 256 frames" );
1141
cu->tb[cu->totbox-1]= cu->tb[cu->totbox-2];
1145
static PyObject *Text3d_removeFrame( BPy_Text3d * self, PyObject * args )
1147
Curve *cu = self->curve;
1150
if (cu->totbox == 1)
1151
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1152
"cannot remove the last frame" );
1154
index = cu->totbox-1;
1156
if( !PyArg_ParseTuple( args, "|i", &index ) )
1157
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
1158
"expected an int" );
1160
if (index < 0 || index >= cu->totbox )
1161
return EXPP_ReturnPyObjError( PyExc_IndexError,
1162
"index out of range" );
1164
for (i = index; i < cu->totbox; i++) cu->tb[i]= cu->tb[i+1];
954
1171
PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * args )
956
1173
char *fontfile= NULL;