php-src/ext/ming/ming.c

3911 lines
110 KiB
C
Raw Normal View History

/*
+----------------------------------------------------------------------+
2004-01-08 08:18:22 +00:00
| PHP Version 5 |
+----------------------------------------------------------------------+
2004-01-08 08:18:22 +00:00
| Copyright (c) 1997-2004 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_0.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dave Hayden <dave@opaque.net> |
| Frank M. Kromann <fmk@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_globals.h"
#include "ext/standard/info.h"
#include "ext/standard/file.h"
2001-08-22 09:20:40 +00:00
#include "ext/standard/fsock.h"
2002-03-15 21:03:08 +00:00
#include "php_streams.h"
2001-08-22 09:20:40 +00:00
#if HAVE_MING
#include "php_ming.h"
#include <stdio.h>
#include <math.h>
#include <ming.h>
2002-11-12 15:09:44 +00:00
#define FLOAT_Z_DVAL_PP(x) ((float)Z_DVAL_PP(x))
#define BYTE_Z_LVAL_PP(x) ((byte)Z_LVAL_PP(x))
#ifndef HAVE_DESTROY_SWF_BLOCK
void destroySWFBlock(SWFBlock block);
#endif
static zend_function_entry ming_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(ming_setcubicthreshold, ming_setCubicThreshold, NULL)
PHP_FALIAS(ming_setscale, ming_setScale, NULL)
PHP_FALIAS(ming_useswfversion, ming_useSWFVersion, NULL)
PHP_FALIAS(swfbutton_keypress, swfbutton_keypress, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(ming_useconstants, ming_useConstants, NULL)
#endif
2002-04-08 00:46:23 +00:00
{ NULL, NULL, NULL }
};
2001-08-07 23:27:01 +00:00
static SWFMovie getMovie(zval *id TSRMLS_DC);
static SWFFill getFill(zval *id TSRMLS_DC);
static SWFGradient getGradient(zval *id TSRMLS_DC);
static SWFBitmap getBitmap(zval *id TSRMLS_DC);
static SWFShape getShape(zval *id TSRMLS_DC);
static SWFFont getFont(zval *id TSRMLS_DC);
static SWFText getText(zval *id TSRMLS_DC);
static SWFTextField getTextField(zval *id TSRMLS_DC);
static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC);
static SWFButton getButton(zval *id TSRMLS_DC);
static SWFAction getAction(zval *id TSRMLS_DC);
static SWFMorph getMorph(zval *id TSRMLS_DC);
static SWFMovieClip getSprite(zval *id TSRMLS_DC);
static SWFSound getSound(zval *id TSRMLS_DC);
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
static SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC);
static SWFSoundInstance getSoundInstance(zval *id TSRMLS_DC);
2003-11-12 09:12:51 +00:00
#endif
2001-05-28 00:09:38 +00:00
#define PHP_MING_FILE_CHK(file) \
if ((PG(safe_mode) && !php_checkuid((file), NULL, CHECKUID_CHECK_FILE_AND_DIR)) || php_check_open_basedir((file) TSRMLS_CC)) { \
RETURN_FALSE; \
} \
2001-12-15 14:22:59 +00:00
/* {{{ proto void ming_setcubicthreshold (int threshold)
2002-04-08 00:46:23 +00:00
Set cubic threshold (?) */
PHP_FUNCTION(ming_setCubicThreshold)
{
2002-04-08 00:46:23 +00:00
zval **num;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(num);
Ming_setCubicThreshold(Z_LVAL_PP(num));
}
2001-12-15 14:22:59 +00:00
/* }}} */
2001-12-15 14:22:59 +00:00
/* {{{ proto void ming_setscale(int scale)
2002-04-08 00:46:23 +00:00
Set scale (?) */
PHP_FUNCTION(ming_setScale)
{
2002-04-08 00:46:23 +00:00
zval **num;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(num);
2002-11-12 15:09:44 +00:00
Ming_setScale(FLOAT_Z_DVAL_PP(num));
}
2001-12-15 14:22:59 +00:00
/* }}} */
2001-12-15 14:22:59 +00:00
/* {{{ proto void ming_useswfversion(int version)
2002-04-08 00:46:23 +00:00
Use SWF version (?) */
PHP_FUNCTION(ming_useSWFVersion)
{
2002-04-08 00:46:23 +00:00
zval **num;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(num);
Ming_useSWFVersion(Z_LVAL_PP(num));
}
2001-12-15 14:22:59 +00:00
/* }}} */
#ifdef HAVE_NEW_MING
/* {{{ proto void ming_useconstants(int use)
Use constant pool (?) */
PHP_FUNCTION(ming_useConstants)
{
zval **num;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(num);
Ming_useConstants(Z_LVAL_PP(num));
}
/* }}} */
#endif
static int le_swfmoviep;
static int le_swfshapep;
static int le_swffillp;
static int le_swfgradientp;
static int le_swfbitmapp;
static int le_swffontp;
static int le_swftextp;
static int le_swftextfieldp;
static int le_swfdisplayitemp;
static int le_swfbuttonp;
static int le_swfactionp;
static int le_swfmorphp;
static int le_swfspritep;
static int le_swfinputp;
static int le_swfsoundp;
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
static int le_swffontcharp;
static int le_swfsoundinstancep;
2003-11-12 09:12:51 +00:00
#endif
static zend_class_entry *movie_class_entry_ptr;
static zend_class_entry *shape_class_entry_ptr;
static zend_class_entry *fill_class_entry_ptr;
static zend_class_entry *gradient_class_entry_ptr;
static zend_class_entry *bitmap_class_entry_ptr;
static zend_class_entry *font_class_entry_ptr;
static zend_class_entry *text_class_entry_ptr;
static zend_class_entry *textfield_class_entry_ptr;
static zend_class_entry *displayitem_class_entry_ptr;
static zend_class_entry *button_class_entry_ptr;
static zend_class_entry *action_class_entry_ptr;
static zend_class_entry *morph_class_entry_ptr;
static zend_class_entry *sprite_class_entry_ptr;
static zend_class_entry *sound_class_entry_ptr;
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
static zend_class_entry *fontchar_class_entry_ptr;
static zend_class_entry *soundinstance_class_entry_ptr;
2003-11-12 09:12:51 +00:00
#endif
/* {{{ internal function SWFgetProperty
*/
2001-08-07 23:27:01 +00:00
static void *SWFgetProperty(zval *id, char *name, int namelen, int proptype TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
zval **tmp;
int id_to_find;
void *property;
int type;
2002-04-08 00:46:23 +00:00
if (id) {
if (zend_hash_find(Z_OBJPROP_P(id), name, namelen+1, (void **)&tmp) == FAILURE) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find property %s", name);
2002-04-08 00:46:23 +00:00
return NULL;
}
id_to_find = Z_LVAL_PP(tmp);
} else {
return NULL;
}
2002-04-08 00:46:23 +00:00
property = zend_list_find(id_to_find, &type);
2002-04-08 00:46:23 +00:00
if (!property || type != proptype) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find identifier (%d)", id_to_find);
2002-04-08 00:46:23 +00:00
return NULL;
}
2002-04-08 00:46:23 +00:00
return property;
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFCharacter - not a real class
*/
/* {{{ internal function SWFCharacter getCharacter(zval *id)
Returns the SWFCharacter contained in zval *id */
2002-04-08 00:46:23 +00:00
static SWFCharacter getCharacter(zval *id TSRMLS_DC)
{
if (Z_OBJCE_P(id) == shape_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getShape(id TSRMLS_CC);
else if (Z_OBJCE_P(id) == font_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getFont(id TSRMLS_CC);
else if (Z_OBJCE_P(id) == text_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getText(id TSRMLS_CC);
else if (Z_OBJCE_P(id) == textfield_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getTextField(id TSRMLS_CC);
else if (Z_OBJCE_P(id) == button_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getButton(id TSRMLS_CC);
else if (Z_OBJCE_P(id) == morph_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getMorph(id TSRMLS_CC);
else if (Z_OBJCE_P(id) == sprite_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getSprite(id TSRMLS_CC);
else if (Z_OBJCE_P(id) == bitmap_class_entry_ptr)
2002-04-08 00:46:23 +00:00
return (SWFCharacter)getBitmap(id TSRMLS_CC);
else if(Z_OBJCE_P(id) == sound_class_entry_ptr)
return (SWFCharacter)getSound(id TSRMLS_CC);
2003-11-06 16:50:40 +00:00
/*
else if(Z_OBJCE_P(id) == soundinstance_class_entry_ptr)
return (SWFCharacter)getSoundInstance(id TSRMLS_CC);
*/
2002-04-08 00:46:23 +00:00
else
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFCharacter");
2002-04-08 00:46:23 +00:00
return NULL;
}
/* }}} */
/* }}} */
/* {{{ getInput - utility func for making an SWFInput from an fopened resource
*/
2001-12-12 15:32:08 +00:00
static void destroy_SWFInput_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFInput((SWFInput)resource->ptr);
}
static SWFInput getInput(zval **zfile TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
FILE *file;
php_stream *stream;
2002-04-08 00:46:23 +00:00
SWFInput input;
php_stream_from_zval_no_verify(stream, zfile);
if (stream == NULL)
return NULL;
if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void *) &file, REPORT_ERRORS) != SUCCESS) {
2002-04-08 00:46:23 +00:00
return NULL;
}
2002-04-08 00:46:23 +00:00
input = newSWFInput_file(file);
zend_list_addref(Z_LVAL_PP(zfile));
zend_list_addref(zend_list_insert(input, le_swfinputp));
return input;
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFAction
*/
static zend_function_entry swfaction_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swfaction, swfaction_init, NULL)
{ NULL, NULL, NULL }
};
/* {{{ proto object swfaction_init(string)
2001-10-09 05:30:21 +00:00
Returns a new SWFAction object, compiling the given script */
PHP_FUNCTION(swfaction_init)
{
2002-04-08 00:46:23 +00:00
SWFAction action;
zval **script;
int ret;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &script) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(script);
action = compileSWFActionCode(Z_STRVAL_PP(script));
2002-04-08 00:46:23 +00:00
if (!action) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Couldn't compile actionscript");
2002-04-08 00:46:23 +00:00
}
ret = zend_list_insert(action, le_swfactionp);
object_init_ex(getThis(), action_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "action", ret);
zend_list_addref(ret);
}
/* no destructor for SWFAction, it's not a character */
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function getAction
Returns the SWFAction object contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFAction getAction(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *action = SWFgetProperty(id, "action", 6, le_swfactionp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!action) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFAction");
2002-04-08 00:46:23 +00:00
}
return (SWFAction)action;
}
/* }}} */
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFBitmap
*/
static zend_function_entry swfbitmap_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swfbitmap, swfbitmap_init, NULL)
PHP_FALIAS(getwidth, swfbitmap_getWidth, NULL)
PHP_FALIAS(getheight, swfbitmap_getHeight, NULL)
{ NULL, NULL, NULL }
};
2003-06-16 15:12:56 +00:00
/* {{{ proto class swfbitmap_init(mixed file [, mixed maskfile])
Returns a new SWFBitmap object from jpg (with optional mask) or dbl file */
PHP_FUNCTION(swfbitmap_init)
{
2002-04-08 00:46:23 +00:00
zval **zfile, **zmask = NULL;
SWFBitmap bitmap;
SWFInput input, maskinput;
int ret;
if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &zfile) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else if (ZEND_NUM_ARGS() == 2) {
if (zend_get_parameters_ex(2, &zfile, &zmask) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else {
WRONG_PARAM_COUNT;
}
if (Z_TYPE_PP(zfile) != IS_RESOURCE) {
convert_to_string_ex(zfile);
PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile));
2002-04-08 00:46:23 +00:00
input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile));
zend_list_addref(zend_list_insert(input, le_swfinputp));
} else {
input = getInput(zfile TSRMLS_CC);
}
if (zmask != NULL) {
if (Z_TYPE_PP(zmask) != IS_RESOURCE) {
convert_to_string_ex(zmask);
maskinput = newSWFInput_buffer(Z_STRVAL_PP(zmask), Z_STRLEN_PP(zmask));
zend_list_addref(zend_list_insert(maskinput, le_swfinputp));
} else {
maskinput = getInput(zmask TSRMLS_CC);
}
bitmap = newSWFJpegWithAlpha_fromInput(input, maskinput);
} else {
bitmap = newSWFBitmap_fromInput(input);
}
ret = zend_list_insert(bitmap, le_swfbitmapp);
object_init_ex(getThis(), bitmap_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "bitmap", ret);
zend_list_addref(ret);
}
2001-07-31 05:44:11 +00:00
static void destroy_SWFBitmap_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFBitmap((SWFBitmap)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function getBitmap
Returns the SWFBitmap object contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFBitmap getBitmap(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *bitmap = SWFgetProperty(id, "bitmap", 6, le_swfbitmapp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!bitmap) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFBitmap");
2002-04-08 00:46:23 +00:00
}
return (SWFBitmap)bitmap;
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto float swfbitmap_getWidth(void)
Returns the width of this bitmap */
PHP_FUNCTION(swfbitmap_getWidth)
{
2002-04-08 00:46:23 +00:00
RETURN_DOUBLE(SWFBitmap_getWidth(getBitmap(getThis() TSRMLS_CC)));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto float swfbitmap_getHeight(void)
Returns the height of this bitmap */
PHP_FUNCTION(swfbitmap_getHeight)
{
2002-04-08 00:46:23 +00:00
RETURN_DOUBLE(SWFBitmap_getHeight(getBitmap(getThis() TSRMLS_CC)));
}
/* }}} */
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFButton
*/
static zend_function_entry swfbutton_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swfbutton, swfbutton_init, NULL)
PHP_FALIAS(sethit, swfbutton_setHit, NULL)
PHP_FALIAS(setover, swfbutton_setOver, NULL)
PHP_FALIAS(setup, swfbutton_setUp, NULL)
PHP_FALIAS(setdown, swfbutton_setDown, NULL)
PHP_FALIAS(setaction, swfbutton_setAction, NULL)
PHP_FALIAS(addshape, swfbutton_addShape, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(setmenu, swfbutton_setMenu, NULL)
#endif
2002-04-08 00:46:23 +00:00
PHP_FALIAS(addaction, swfbutton_addAction, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(addsound, swfbutton_addSound, NULL)
#endif
2002-04-08 00:46:23 +00:00
{ NULL, NULL, NULL }
};
/* {{{ proto object swfbutton_init(void)
2001-10-09 05:30:21 +00:00
Returns a new SWFButton object */
PHP_FUNCTION(swfbutton_init)
{
2002-04-08 00:46:23 +00:00
SWFButton button = newSWFButton();
int ret = zend_list_insert(button, le_swfbuttonp);
object_init_ex(getThis(), button_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "button", ret);
zend_list_addref(ret);
}
2002-04-08 00:46:23 +00:00
2001-07-31 05:44:11 +00:00
static void destroy_SWFButton_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFButton((SWFButton)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function getButton
Returns the SWFButton object contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFButton getButton(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *button = SWFgetProperty(id, "button", 6, le_swfbuttonp TSRMLS_CC);
if (!button) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFButton");
2002-04-08 00:46:23 +00:00
}
return (SWFButton)button;
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfbutton_setHit(object SWFCharacter)
2001-10-09 05:30:21 +00:00
Sets the character for this button's hit test state */
PHP_FUNCTION(swfbutton_setHit)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFCharacter character;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_object_ex(zchar);
character = getCharacter(*zchar TSRMLS_CC);
SWFButton_addShape(button, character, SWFBUTTONRECORD_HITSTATE);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfbutton_setOver(object SWFCharacter)
2001-10-09 05:30:21 +00:00
Sets the character for this button's over state */
PHP_FUNCTION(swfbutton_setOver)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFCharacter character;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
character = getCharacter(*zchar TSRMLS_CC);
SWFButton_addShape(button, character, SWFBUTTONRECORD_OVERSTATE);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfbutton_setUp(object SWFCharacter)
2001-10-09 05:30:21 +00:00
Sets the character for this button's up state */
PHP_FUNCTION(swfbutton_setUp)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFCharacter character;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
2002-04-08 00:46:23 +00:00
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
character = getCharacter(*zchar TSRMLS_CC);
SWFButton_addShape(button, character, SWFBUTTONRECORD_UPSTATE);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfbutton_setDown(object SWFCharacter)
2001-10-09 05:30:21 +00:00
Sets the character for this button's down state */
PHP_FUNCTION(swfbutton_setDown)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFCharacter character;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
character = getCharacter(*zchar TSRMLS_CC);
SWFButton_addShape(button, character, SWFBUTTONRECORD_DOWNSTATE);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfbutton_addShape(object SWFCharacter, int flags)
2001-10-09 05:30:21 +00:00
Sets the character to display for the condition described in flags */
PHP_FUNCTION(swfbutton_addShape)
{
2002-04-08 00:46:23 +00:00
zval **zchar, **flags;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFCharacter character;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zchar, &flags) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
character = getCharacter(*zchar TSRMLS_CC);
convert_to_long_ex(flags);
2002-11-12 15:09:44 +00:00
SWFButton_addShape(button, character, BYTE_Z_LVAL_PP(flags));
}
/* }}} */
2002-04-08 00:46:23 +00:00
#ifdef HAVE_NEW_MING
/* {{{ proto void swfbutton_setMenu(int flag)
enable track as menu button behaviour */
PHP_FUNCTION(swfbutton_setMenu)
{
zval **zflag;
SWFButton button = getButton(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zflag) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(zflag);
SWFButton_setMenu(button, Z_LVAL_PP(zflag));
}
/* }}} */
#endif
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfbutton_setAction(object SWFAction)
2001-10-09 05:30:21 +00:00
Sets the action to perform when button is pressed */
PHP_FUNCTION(swfbutton_setAction)
{
2002-04-08 00:46:23 +00:00
zval **zaction;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFAction action;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zaction) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zaction);
action = getAction(*zaction TSRMLS_CC);
SWFButton_addAction(button, action, SWFBUTTON_OVERDOWNTOOVERUP);
}
/* }}} */
2002-04-08 00:46:23 +00:00
#ifdef HAVE_NEW_MING
/* {{{ proto SWFSoundInstance * swfbutton_addASound(SWFSound sound, int flags)
associates a sound with a button transition
NOTE: the transitions are all wrong _UP, _OVER, _DOWN _HIT */
PHP_FUNCTION(swfbutton_addSound)
{
zval **zsound, **flags;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFSound sound;
SWFSoundInstance item;
int ret;
if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zsound, &flags) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_object_ex(zsound);
sound = getSound(*zsound TSRMLS_CC);
convert_to_long_ex(flags);
item = SWFButton_addSound(button, sound, Z_LVAL_PP(flags));
if(item != NULL) {
/* try and create a soundinstance object */
ret = zend_list_insert(item, le_swfsoundinstancep);
object_init_ex(return_value, soundinstance_class_entry_ptr);
add_property_resource(return_value, "soundinstance", ret);
}
}
/* }}} */
#endif
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfbutton_addAction(object SWFAction, int flags)
2001-10-09 05:30:21 +00:00
Sets the action to perform when conditions described in flags is met */
PHP_FUNCTION(swfbutton_addAction)
{
2002-04-08 00:46:23 +00:00
zval **zaction, **flags;
SWFButton button = getButton(getThis() TSRMLS_CC);
SWFAction action;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zaction, &flags) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zaction);
action = getAction(*zaction TSRMLS_CC);
convert_to_long_ex(flags);
SWFButton_addAction(button, action, Z_LVAL_PP(flags));
}
/* }}} */
2001-12-15 14:22:59 +00:00
/* {{{ proto int swfbutton_keypress(string str)
2002-04-08 00:46:23 +00:00
Returns the action flag for keyPress(char) */
PHP_FUNCTION(swfbutton_keypress)
{
2002-04-08 00:46:23 +00:00
zval **key;
char c;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &key) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(key);
2002-04-08 00:46:23 +00:00
if (Z_STRLEN_PP(key) > 1) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Only one character expected");
2002-04-08 00:46:23 +00:00
}
c = Z_STRVAL_PP(key)[0];
RETURN_LONG((c&0x7f)<<9);
}
/* }}} */
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFDisplayitem
*/
static zend_function_entry swfdisplayitem_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(moveto, swfdisplayitem_moveTo, NULL)
PHP_FALIAS(move, swfdisplayitem_move, NULL)
PHP_FALIAS(scaleto, swfdisplayitem_scaleTo, NULL)
PHP_FALIAS(scale, swfdisplayitem_scale, NULL)
PHP_FALIAS(rotateto, swfdisplayitem_rotateTo, NULL)
PHP_FALIAS(rotate, swfdisplayitem_rotate, NULL)
PHP_FALIAS(skewxto, swfdisplayitem_skewXTo, NULL)
PHP_FALIAS(skewx, swfdisplayitem_skewX, NULL)
PHP_FALIAS(skewyto, swfdisplayitem_skewYTo, NULL)
PHP_FALIAS(skewy, swfdisplayitem_skewY, NULL)
PHP_FALIAS(setmatrix, swfdisplayitem_setMatrix, NULL)
PHP_FALIAS(setdepth, swfdisplayitem_setDepth, NULL)
PHP_FALIAS(setratio, swfdisplayitem_setRatio, NULL)
PHP_FALIAS(addcolor, swfdisplayitem_addColor, NULL)
PHP_FALIAS(multcolor, swfdisplayitem_multColor, NULL)
PHP_FALIAS(setname, swfdisplayitem_setName, NULL)
PHP_FALIAS(addaction, swfdisplayitem_addAction, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(remove, swfdisplayitem_remove, NULL)
PHP_FALIAS(setmasklevel, swfdisplayitem_setMaskLevel,NULL)
PHP_FALIAS(endmask, swfdisplayitem_endMask, NULL)
PHP_FALIAS(get_x, swfdisplayitem_getX, NULL)
PHP_FALIAS(get_y, swfdisplayitem_getY, NULL)
PHP_FALIAS(get_xscale, swfdisplayitem_getXScale, NULL)
PHP_FALIAS(get_yscale, swfdisplayitem_getYScale, NULL)
PHP_FALIAS(get_xskew, swfdisplayitem_getXSkew, NULL)
PHP_FALIAS(get_yskew, swfdisplayitem_getYSkew, NULL)
PHP_FALIAS(get_rot, swfdisplayitem_getRot, NULL)
#endif
2002-04-08 00:46:23 +00:00
{ NULL, NULL, NULL }
};
/* {{{ internal function getDisplayItem
Returns the SWFDisplayItem contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFDisplayItem getDisplayItem(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *item = SWFgetProperty(id, "displayitem", 11, le_swfdisplayitemp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!item) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFDisplayItem");
2002-04-08 00:46:23 +00:00
}
2002-04-08 00:46:23 +00:00
return (SWFDisplayItem)item;
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_moveTo(int x, int y)
2001-10-09 05:30:21 +00:00
Moves this SWFDisplayItem to movie coordinates (x, y) */
PHP_FUNCTION(swfdisplayitem_moveTo)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_moveTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfdisplayitem_move(float dx, float dy)
2001-10-09 05:30:21 +00:00
Displaces this SWFDisplayItem by (dx, dy) in movie coordinates */
PHP_FUNCTION(swfdisplayitem_move)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_move(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swfdisplayitem_scaleTo(float xScale [, float yScale])
Scales this SWFDisplayItem by xScale in the x direction, yScale in the y, or both to xScale if only one arg */
PHP_FUNCTION(swfdisplayitem_scaleTo)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &x) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(x));
2002-04-08 00:46:23 +00:00
} else if (ZEND_NUM_ARGS() == 2) {
if (zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_scaleTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
2002-04-08 00:46:23 +00:00
} else {
WRONG_PARAM_COUNT;
}
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_scale(float xScale, float yScale)
2001-10-09 05:30:21 +00:00
Multiplies this SWFDisplayItem's current x scale by xScale, its y scale by yScale */
PHP_FUNCTION(swfdisplayitem_scale)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_scale(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_rotateTo(float degrees)
2001-10-09 05:30:21 +00:00
Rotates this SWFDisplayItem the given (clockwise) degrees from its original orientation */
PHP_FUNCTION(swfdisplayitem_rotateTo)
{
2002-04-08 00:46:23 +00:00
zval **degrees;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &degrees) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(degrees);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_rotateTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_rotate(float degrees)
2001-10-09 05:30:21 +00:00
Rotates this SWFDisplayItem the given (clockwise) degrees from its current orientation */
PHP_FUNCTION(swfdisplayitem_rotate)
{
2002-04-08 00:46:23 +00:00
zval **degrees;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &degrees) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(degrees);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_rotate(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_skewXTo(float xSkew)
Sets this SWFDisplayItem's x skew value to xSkew */
PHP_FUNCTION(swfdisplayitem_skewXTo)
{
2002-04-08 00:46:23 +00:00
zval **x;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_skewXTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_skewX(float xSkew)
Adds xSkew to this SWFDisplayItem's x skew value */
PHP_FUNCTION(swfdisplayitem_skewX)
{
2002-04-08 00:46:23 +00:00
zval **x;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_skewX(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_skewYTo(float ySkew)
Sets this SWFDisplayItem's y skew value to ySkew */
PHP_FUNCTION(swfdisplayitem_skewYTo)
{
2002-04-08 00:46:23 +00:00
zval **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_skewYTo(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_skewY(float ySkew)
Adds ySkew to this SWFDisplayItem's y skew value */
PHP_FUNCTION(swfdisplayitem_skewY)
{
2002-04-08 00:46:23 +00:00
zval **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_skewY(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_setMatrix(float a, float b, float c, float d, float x, float y)
Sets the item's transform matrix */
PHP_FUNCTION(swfdisplayitem_setMatrix)
{
2002-04-08 00:46:23 +00:00
zval **a, **b, **c, **d, **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &a, &b, &c, &d, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(a);
convert_to_double_ex(b);
convert_to_double_ex(c);
convert_to_double_ex(d);
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-04-08 00:46:23 +00:00
SWFDisplayItem_setMatrix( getDisplayItem(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
FLOAT_Z_DVAL_PP(a), FLOAT_Z_DVAL_PP(b), FLOAT_Z_DVAL_PP(c), FLOAT_Z_DVAL_PP(d), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y)
2002-04-08 00:46:23 +00:00
);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_setDepth(int depth)
2001-10-09 05:30:21 +00:00
Sets this SWFDisplayItem's z-depth to depth. Items with higher depth values are drawn on top of those with lower values */
PHP_FUNCTION(swfdisplayitem_setDepth)
{
2002-04-08 00:46:23 +00:00
zval **depth;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &depth) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(depth);
SWFDisplayItem_setDepth(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(depth));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_setRatio(float ratio)
2001-10-09 05:30:21 +00:00
Sets this SWFDisplayItem's ratio to ratio. Obviously only does anything if displayitem was created from an SWFMorph */
PHP_FUNCTION(swfdisplayitem_setRatio)
{
2002-04-08 00:46:23 +00:00
zval **ratio;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ratio) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(ratio);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_setRatio(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(ratio));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_addColor(int r, int g, int b [, int a])
2001-10-09 05:30:21 +00:00
Sets the add color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 0 */
PHP_FUNCTION(swfdisplayitem_addColor)
{
2002-04-08 00:46:23 +00:00
zval **r, **g, **b, **za;
int a = 0;
if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(za);
a = Z_LVAL_PP(za);
} else if (ZEND_NUM_ARGS() == 3) {
if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
2002-04-08 00:46:23 +00:00
SWFDisplayItem_setColorAdd(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b), a);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_multColor(float r, float g, float b [, float a])
Sets the multiply color part of this SWFDisplayItem's CXform to (r, g, b [, a]), a defaults to 1.0 */
PHP_FUNCTION(swfdisplayitem_multColor)
{
2002-04-08 00:46:23 +00:00
zval **r, **g, **b, **za;
2002-11-12 15:09:44 +00:00
float a = 1.0f;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(za);
2002-11-12 15:09:44 +00:00
a = FLOAT_Z_DVAL_PP(za);
} else if (ZEND_NUM_ARGS() == 3) {
2002-04-08 00:46:23 +00:00
if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(r);
convert_to_double_ex(g);
convert_to_double_ex(b);
2002-11-12 15:09:44 +00:00
SWFDisplayItem_setColorMult(getDisplayItem(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r), FLOAT_Z_DVAL_PP(g), FLOAT_Z_DVAL_PP(b), a);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfdisplayitem_setName(string name)
2001-10-09 05:30:21 +00:00
Sets this SWFDisplayItem's name to name */
PHP_FUNCTION(swfdisplayitem_setName)
{
2002-04-08 00:46:23 +00:00
zval **name;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(name);
SWFDisplayItem_setName(item, Z_STRVAL_PP(name));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfdisplayitem_addAction(object SWFAction, int flags)
2001-10-09 05:30:21 +00:00
Adds this SWFAction to the given SWFSprite instance */
PHP_FUNCTION(swfdisplayitem_addAction)
{
2002-04-08 00:46:23 +00:00
zval **zaction, **flags;
SWFAction action;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zaction, &flags) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_object_ex(zaction);
convert_to_long_ex(flags);
action = getAction(*zaction TSRMLS_CC);
2002-04-08 00:46:23 +00:00
SWFDisplayItem_addAction(item, action, Z_LVAL_PP(flags));
}
/* }}} */
#ifdef HAVE_NEW_MING
/* {{{ swfdisplayitem_remove */
PHP_FUNCTION(swfdisplayitem_remove)
{
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
SWFDisplayItem_remove(item);
}
/* }}} */
/* {{{ proto void swfdisplayitem_setMaskLevel(int level)
defines a MASK layer at level */
PHP_FUNCTION(swfdisplayitem_setMaskLevel)
{
zval **level;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &level) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(level);
SWFDisplayItem_setMaskLevel(getDisplayItem(getThis() TSRMLS_CC), Z_LVAL_PP(level));
}
/* }}} */
/* {{{ proto void swfdisplayitem_endMask()
another way of defining a MASK layer */
PHP_FUNCTION(swfdisplayitem_endMask)
{
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
SWFDisplayItem_endMask(item);
}
/* }}} */
/* {{{ swfdisplayitem_getX */
PHP_FUNCTION(swfdisplayitem_getX)
{
float ret;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
ret = SWFDisplayItem_get_x(item);
RETURN_DOUBLE(ret);
}
/* }}} */
/* {{{ swfdisplayitem_getY */
PHP_FUNCTION(swfdisplayitem_getY)
{
float ret;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
ret = SWFDisplayItem_get_y(item);
RETURN_DOUBLE(ret);
}
/* }}} */
/* {{{ swfdisplayitem_getXScale */
PHP_FUNCTION(swfdisplayitem_getXScale)
{
float ret;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
ret = SWFDisplayItem_get_xScale(item);
RETURN_DOUBLE(ret);
}
/* }}} */
/* {{{ swfdisplayitem_getYScale */
PHP_FUNCTION(swfdisplayitem_getYScale)
{
float ret;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
ret = SWFDisplayItem_get_yScale(item);
RETURN_DOUBLE(ret);
}
/* }}} */
/* {{{ swfdisplayitem_getXSkew */
PHP_FUNCTION(swfdisplayitem_getXSkew)
{
float ret;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
ret = SWFDisplayItem_get_xSkew(item);
RETURN_DOUBLE(ret);
}
/* }}} */
/* {{{ swfdisplayitem_getYSkew */
PHP_FUNCTION(swfdisplayitem_getYSkew)
{
float ret;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
ret = SWFDisplayItem_get_ySkew(item);
RETURN_DOUBLE(ret);
}
/* }}} */
/* {{{ swfdisplayitem_getRot */
PHP_FUNCTION(swfdisplayitem_getRot)
{
float ret;
SWFDisplayItem item = getDisplayItem(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
ret = SWFDisplayItem_get_rot(item);
RETURN_DOUBLE(ret);
}
/* }}} */
#endif
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFFill
*/
static zend_function_entry swffill_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swffill, swffill_init, NULL)
PHP_FALIAS(moveto, swffill_moveTo, NULL)
PHP_FALIAS(scaleto, swffill_scaleTo, NULL)
PHP_FALIAS(rotateto, swffill_rotateTo, NULL)
PHP_FALIAS(skewxto, swffill_skewXTo, NULL)
PHP_FALIAS(skewyto, swffill_skewYTo, NULL)
{ NULL, NULL, NULL }
};
/* {{{ proto class swffill_init(void)
Returns a new SWFFill object */
PHP_FUNCTION(swffill_init)
{
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Instantiating SWFFill won't do any good- use SWFShape::addFill() instead");
}
2002-04-08 00:46:23 +00:00
2001-07-31 05:44:11 +00:00
static void destroy_SWFFill_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
/* this only destroys the shallow wrapper for SWFFillStyle,
which SWFShape destroys. So everything's okay. I hope. */
2002-04-08 00:46:23 +00:00
destroySWFFill((SWFFill)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function getFill
Returns the SWFFill object contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFFill getFill(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *fill = SWFgetProperty(id, "fill", 4, le_swffillp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!fill) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFill");
2002-04-08 00:46:23 +00:00
}
return (SWFFill)fill;
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swffill_moveTo(float x, float y)
Moves this SWFFill to shape coordinates (x,y) */
PHP_FUNCTION(swffill_moveTo)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFFill_moveTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swffill_scaleTo(float xScale [, float yScale])
Scales this SWFFill by xScale in the x direction, yScale in the y, or both to xScale if only one arg */
PHP_FUNCTION(swffill_scaleTo)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &x) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
2002-11-12 15:09:44 +00:00
SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(x));
2002-04-08 00:46:23 +00:00
} else if (ZEND_NUM_ARGS() == 2) {
if (zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFFill_scaleXYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
2002-04-08 00:46:23 +00:00
} else {
WRONG_PARAM_COUNT;
}
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swffill_rotateTo(float degrees)
2001-10-09 05:30:21 +00:00
Rotates this SWFFill the given (clockwise) degrees from its original orientation */
PHP_FUNCTION(swffill_rotateTo)
{
2002-04-08 00:46:23 +00:00
zval **degrees;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &degrees) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(degrees);
2002-11-12 15:09:44 +00:00
SWFFill_rotateTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(degrees));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swffill_skewXTo(float xSkew)
Sets this SWFFill's x skew value to xSkew */
PHP_FUNCTION(swffill_skewXTo)
{
2002-04-08 00:46:23 +00:00
zval **x;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &x) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
2002-11-12 15:09:44 +00:00
SWFFill_skewXTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swffill_skewYTo(float ySkew)
Sets this SWFFill's y skew value to ySkew */
PHP_FUNCTION(swffill_skewYTo)
{
2002-04-08 00:46:23 +00:00
zval **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFFill_skewYTo(getFill(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
/* }}} */
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
/* {{{ SWFFontCharacter */
static zend_function_entry swffontchar_functions[] = {
PHP_FALIAS(addchars, swffontchar_addChars, NULL)
PHP_FALIAS(addutf8chars, swffontchar_addUTF8Chars, NULL)
{ NULL, NULL, NULL }
};
/* {{{ internal function SWFText getFont(zval *id)
Returns the Font object in zval *id */
static
SWFFontCharacter getFontCharacter(zval *id TSRMLS_DC)
{
void *font = SWFgetProperty(id, "fontcharacter", 13, le_swffontcharp TSRMLS_CC);
if(!font)
php_error(E_ERROR, "called object is not an SWFFontCharacter!");
return (SWFFontCharacter)font;
}
static void destroy_SWFFontCharacter_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
destroySWFBlock((SWFBlock)resource->ptr);
}
/* {{{ proto void swffontchar_addChars(string)
adds characters to a font for exporting font */
PHP_FUNCTION(swffontchar_addChars)
{
zval **zstring;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
SWFFontCharacter_addChars(getFontCharacter(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
}
/* }}} */
/* {{{ proto void swffontchar_addChars(string)
adds characters to a font for exporting font */
PHP_FUNCTION(swffontchar_addUTF8Chars)
{
zval **zstring;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
SWFFontCharacter_addUTF8Chars(getFontCharacter(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
}
/* }}} */
/* }}} */
2003-11-12 09:12:51 +00:00
#endif
2002-04-08 00:46:23 +00:00
/* {{{ SWFFont
*/
static zend_function_entry swffont_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swffont, swffont_init, NULL)
PHP_FALIAS(getwidth, swffont_getWidth, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(getutf8width, swffont_getUTF8Width, NULL)
/* PHP_FALIAS(getwidewidth, swffont_getWideWidth, NULL)*/
#endif
2002-04-08 00:46:23 +00:00
PHP_FALIAS(getascent, swffont_getAscent, NULL)
PHP_FALIAS(getdescent, swffont_getDescent, NULL)
PHP_FALIAS(getleading, swffont_getLeading, NULL)
#ifdef HAVE_NEW_MING
/* PHP_FALIAS(addchars, swffont_addChars, NULL)*/
PHP_FALIAS(getshape, swffont_getShape, NULL)
#endif
2002-04-08 00:46:23 +00:00
{ NULL, NULL, NULL }
};
/* {{{ internal function SWFText getFont(zval *id)
Returns the Font object in zval *id */
2002-04-08 00:46:23 +00:00
static SWFFont getFont(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *font = SWFgetProperty(id, "font", 4, le_swffontp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!font) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFFont");
2002-04-08 00:46:23 +00:00
}
return (SWFFont)font;
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto object swffont_init(string filename)
Returns a new SWFFont object from given file */
PHP_FUNCTION(swffont_init)
{
2002-04-08 00:46:23 +00:00
zval **zfile;
SWFFont font;
int ret;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfile) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_string_ex(zfile);
2002-04-08 00:46:23 +00:00
if (strcmp(Z_STRVAL_PP(zfile)+Z_STRLEN_PP(zfile)-4, ".fdb") == 0) {
php_stream * stream;
FILE * file;
2002-03-16 15:15:51 +00:00
2002-04-08 00:46:23 +00:00
stream = php_stream_open_wrapper(Z_STRVAL_PP(zfile), "rb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
2002-03-16 15:15:51 +00:00
2002-04-08 00:46:23 +00:00
if (stream == NULL) {
RETURN_FALSE;
}
2002-03-16 15:15:51 +00:00
2002-04-08 00:46:23 +00:00
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void*)&file, REPORT_ERRORS)) {
php_stream_close(stream);
RETURN_FALSE;
}
font = loadSWFFontFromFile(file);
2002-03-16 15:15:51 +00:00
php_stream_close(stream);
2002-04-08 00:46:23 +00:00
} else {
PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile));
font = (SWFFont)newSWFBrowserFont(Z_STRVAL_PP(zfile));
2002-03-16 15:15:51 +00:00
}
2002-04-08 00:46:23 +00:00
ret = zend_list_insert(font, le_swffontp);
object_init_ex(getThis(), font_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "font", ret);
zend_list_addref(ret);
}
2002-03-16 22:19:33 +00:00
2001-07-31 05:44:11 +00:00
static void destroy_SWFFont_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFBlock((SWFBlock)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto float swffont_getWidth(string str)
2001-10-09 05:30:21 +00:00
Calculates the width of the given string in this font at full height */
PHP_FUNCTION(swffont_getWidth)
{
2002-04-08 00:46:23 +00:00
zval **zstring;
float width;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(zstring);
width = SWFFont_getStringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
RETURN_DOUBLE(width);
}
/* }}} */
2002-04-08 00:46:23 +00:00
#ifdef HAVE_NEW_MING
/* {{{ proto int swffont_getUTF8Width(string)
Calculates the width of the given string in this font at full height */
PHP_FUNCTION(swffont_getUTF8Width)
{
zval **zstring;
float width;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
width = SWFFont_getUTF8StringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
RETURN_DOUBLE(width);
}
/* }}} */
2003-11-06 16:50:40 +00:00
/* not sure about 0 bytes !!!!!!!!! */
/* {{{ proto int swffont_getWideWidth(string)
Calculates the width of the given string in this font at full height */
/*
PHP_FUNCTION(swffont_getWideWidth)
{
zval **zstring;
float width;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
width = SWFFont_getWideStringWidth(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
RETURN_DOUBLE(width);
}
*/
/* }}} */
#endif
2003-06-16 15:12:56 +00:00
/* {{{ proto float swffont_getAscent(void)
2001-10-09 05:30:21 +00:00
Returns the ascent of the font, or 0 if not available */
PHP_FUNCTION(swffont_getAscent)
{
2002-04-08 00:46:23 +00:00
RETURN_DOUBLE(SWFFont_getAscent(getFont(getThis() TSRMLS_CC)));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto float swffont_getDescent(void)
2001-10-09 05:30:21 +00:00
Returns the descent of the font, or 0 if not available */
PHP_FUNCTION(swffont_getDescent)
{
2002-04-08 00:46:23 +00:00
RETURN_DOUBLE(SWFFont_getDescent(getFont(getThis() TSRMLS_CC)));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto float swffont_getLeading(void)
2001-10-09 05:30:21 +00:00
Returns the leading of the font, or 0 if not available */
PHP_FUNCTION(swffont_getLeading)
{
2002-04-08 00:46:23 +00:00
RETURN_DOUBLE(SWFFont_getLeading(getFont(getThis() TSRMLS_CC)));
}
/* }}} */
#ifdef HAVE_NEW_MING
/* {{{ proto void swffont_addChars(string)
adds characters to a font required within textfields */
/*
PHP_FUNCTION(swffont_addChars)
{
zval **zstring;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
SWFFont_addChars(getFont(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
}
*/
/* }}} */
/* {{{ proto char *swffont_getShape(code)
Returns the glyph shape of a char as a text string */
PHP_FUNCTION(swffont_getShape)
{
zval **zcode;
char *result;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zcode) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(zcode);
result = SWFFont_getShape(getFont(getThis() TSRMLS_CC), Z_LVAL_PP(zcode));
RETVAL_STRING(result, 1);
free(result);
}
/* }}} */
2003-11-12 09:12:51 +00:00
/* }}} */
#endif
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFGradient
*/
static zend_function_entry swfgradient_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swfgradient, swfgradient_init, NULL)
PHP_FALIAS(addentry, swfgradient_addEntry, NULL)
{ NULL, NULL, NULL }
};
/* {{{ proto class swfgradient_init(void)
Returns a new SWFGradient object */
PHP_FUNCTION(swfgradient_init)
{
2002-04-08 00:46:23 +00:00
SWFGradient gradient = newSWFGradient();
int ret = zend_list_insert(gradient, le_swfgradientp);
object_init_ex(getThis(), gradient_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "gradient", ret);
zend_list_addref(ret);
}
2001-07-31 05:44:11 +00:00
static void destroy_SWFGradient_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFGradient((SWFGradient)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function getGradient
Returns the SWFGradient object contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFGradient getGradient(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *gradient = SWFgetProperty(id, "gradient", 8, le_swfgradientp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!gradient) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFGradient");
2002-04-08 00:46:23 +00:00
}
return (SWFGradient)gradient;
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfgradient_addEntry(float ratio, int r, int g, int b [, int a])
2002-04-08 00:46:23 +00:00
Adds given entry to the gradient */
PHP_FUNCTION(swfgradient_addEntry)
{
2002-04-08 00:46:23 +00:00
zval **ratio, **r, **g, **b;
byte a = 0xff;
if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &ratio, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else if (ZEND_NUM_ARGS() == 5) {
zval **za;
if (zend_get_parameters_ex(5, &ratio, &r, &g, &b, &za) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(za);
2002-11-12 21:11:01 +00:00
a = BYTE_Z_LVAL_PP(za);
2002-04-08 00:46:23 +00:00
} else {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(ratio);
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
2002-04-08 00:46:23 +00:00
SWFGradient_addEntry( getGradient(getThis() TSRMLS_CC),
2002-11-12 21:11:01 +00:00
FLOAT_Z_DVAL_PP(ratio), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), a
2002-04-08 00:46:23 +00:00
);
}
/* }}} */
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFMorph
*/
static zend_function_entry swfmorph_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swfmorph, swfmorph_init, NULL)
PHP_FALIAS(getshape1, swfmorph_getShape1, NULL)
PHP_FALIAS(getshape2, swfmorph_getShape2, NULL)
{ NULL, NULL, NULL }
};
/* {{{ proto object swfmorph_init(void)
Returns a new SWFMorph object */
PHP_FUNCTION(swfmorph_init)
{
SWFMorph morph = newSWFMorphShape();
int ret = zend_list_insert(morph, le_swfmorphp);
object_init_ex(getThis(), morph_class_entry_ptr);
add_property_resource(getThis(), "morph", ret);
zend_list_addref(ret);
}
static void destroy_SWFMorph_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
destroySWFMorph((SWFMorph)resource->ptr);
}
/* }}} */
/* {{{ internal function getMorph
Returns the SWFMorph object contained in zval *id */
static SWFMorph getMorph(zval *id TSRMLS_DC)
{
void *morph = SWFgetProperty(id, "morph", 5, le_swfmorphp TSRMLS_CC);
if (!morph) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMorph");
}
return (SWFMorph)morph;
}
/* }}} */
/* {{{ proto object swfmorph_getShape1(void)
Return's this SWFMorph's start shape object */
PHP_FUNCTION(swfmorph_getShape1)
{
SWFMorph morph = getMorph(getThis() TSRMLS_CC);
SWFShape shape = SWFMorph_getShape1(morph);
int ret = zend_list_insert(shape, le_swfshapep);
object_init_ex(return_value, shape_class_entry_ptr);
add_property_resource(return_value, "shape", ret);
zend_list_addref(ret);
}
/* }}} */
/* {{{ proto object swfmorph_getShape2(void)
Return's this SWFMorph's start shape object */
PHP_FUNCTION(swfmorph_getShape2)
{
SWFMorph morph = getMorph(getThis() TSRMLS_CC);
SWFShape shape = SWFMorph_getShape2(morph);
int ret = zend_list_insert(shape, le_swfshapep);
object_init_ex(return_value, shape_class_entry_ptr);
add_property_resource(return_value, "shape", ret);
zend_list_addref(ret);
}
/* }}} */
/* }}} */
/* {{{ SWFSound */
static zend_function_entry swfsound_functions[] = {
PHP_FALIAS(swfsound, swfsound_init, NULL)
{ NULL, NULL, NULL }
};
/* {{{ internal function SWFSound getSound(zval *id)
Returns the Sound object in zval *id */
SWFSound getSound(zval *id TSRMLS_DC)
{
void *sound = SWFgetProperty(id, "sound", 5, le_swfsoundp TSRMLS_CC);
if(!sound)
php_error(E_ERROR, "called object is not an SWFSound!");
return (SWFSound)sound;
}
/* }}} */
/* {{{ proto class swfsound_init(string filename, int flags)
Returns a new SWFSound object from given file */
PHP_FUNCTION(swfsound_init)
{
zval **zfile, **zflags;
SWFSound sound;
SWFInput input;
int flags;
int ret;
if(ZEND_NUM_ARGS() == 1)
{
if(zend_get_parameters_ex(1, &zfile) == FAILURE)
WRONG_PARAM_COUNT;
flags = 0;
}
else if(ZEND_NUM_ARGS() == 2)
{
if(zend_get_parameters_ex(2, &zfile, &zflags) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(zflags);
flags = Z_LVAL_PP(zflags);
}
else
WRONG_PARAM_COUNT;
if(Z_TYPE_PP(zfile) != IS_RESOURCE)
{
convert_to_string_ex(zfile);
PHP_MING_FILE_CHK(Z_STRVAL_PP(zfile));
input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile));
zend_list_addref(zend_list_insert(input, le_swfinputp));
}
else
input = getInput(zfile TSRMLS_CC);
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
sound = newSWFSound_fromInput(input, flags);
2003-11-12 09:12:51 +00:00
#else
sound = newSWFSound_fromInput(input);
#endif
ret = zend_list_insert(sound, le_swfsoundp);
object_init_ex(getThis(), sound_class_entry_ptr);
add_property_resource(getThis(), "sound", ret);
zend_list_addref(ret);
}
static void destroy_SWFSound_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
destroySWFBlock((SWFBlock)resource->ptr);
}
/* }}} */
/* }}} */
#ifdef HAVE_NEW_MING
/* should handle envelope functions */
/* {{{ SWFSoundInstance */
static zend_function_entry swfsoundinstance_functions[] = {
PHP_FALIAS(nomultiple, swfsoundinstance_noMultiple, NULL)
PHP_FALIAS(loopinpoint, swfsoundinstance_loopInPoint, NULL)
PHP_FALIAS(loopoutpoint, swfsoundinstance_loopOutPoint, NULL)
PHP_FALIAS(loopcount, swfsoundinstance_loopCount, NULL)
{ NULL, NULL, NULL }
};
/* {{{ internal function SWFSoundInstance getSoundInstance(zval *id)
Returns the SoundInstance object in zval *id */
SWFSoundInstance getSoundInstance(zval *id TSRMLS_DC)
{
void *inst = SWFgetProperty(id, "soundinstance", 13, le_swfsoundinstancep TSRMLS_CC);
if (!inst)
php_error(E_ERROR, "called object is not an SWFSoundInstance!");
return (SWFSoundInstance)inst;
}
/* }}} */
2001-07-31 05:44:11 +00:00
/* {{{ swfsoundinstance_nomultiple */
PHP_FUNCTION(swfsoundinstance_noMultiple)
{
SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 0)
WRONG_PARAM_COUNT;
SWFSoundInstance_setNoMultiple(inst);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ swfsoundinstance_loopinpoint(point) */
PHP_FUNCTION(swfsoundinstance_loopInPoint)
{
zval **zpoint;
SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zpoint) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(zpoint);
SWFSoundInstance_setLoopInPoint(inst, Z_LVAL_PP(zpoint));
}
/* }}} */
/* {{{ swfsoundinstance_loopoutpoint(point) */
2002-04-08 00:46:23 +00:00
PHP_FUNCTION(swfsoundinstance_loopOutPoint)
{
zval **zpoint;
SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zpoint) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(zpoint);
SWFSoundInstance_setLoopOutPoint(inst, Z_LVAL_PP(zpoint));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ swfsoundinstance_loopcount(point) */
PHP_FUNCTION(swfsoundinstance_loopCount)
{
zval **zcount;
SWFSoundInstance inst = getSoundInstance(getThis() TSRMLS_CC);
if((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &zcount) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(zcount);
SWFSoundInstance_setLoopCount(inst, Z_LVAL_PP(zcount));
}
/* }}} */
/* }}} */
#endif
2002-04-08 00:46:23 +00:00
/* {{{ SWFMovie
*/
static zend_function_entry swfmovie_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swfmovie, swfmovie_init, NULL)
PHP_FALIAS(nextframe, swfmovie_nextFrame, NULL)
PHP_FALIAS(labelframe, swfmovie_labelFrame, NULL)
PHP_FALIAS(add, swfmovie_add, NULL)
PHP_FALIAS(remove, swfmovie_remove, NULL)
PHP_FALIAS(output, swfmovie_output, NULL)
PHP_FALIAS(save, swfmovie_save, NULL)
PHP_FALIAS(savetofile, swfmovie_saveToFile, NULL)
PHP_FALIAS(setbackground, swfmovie_setBackground, NULL)
PHP_FALIAS(setrate, swfmovie_setRate, NULL)
PHP_FALIAS(setdimension, swfmovie_setDimension, NULL)
PHP_FALIAS(setframes, swfmovie_setFrames, NULL)
#ifdef HAVE_NEW_MING
2002-04-08 00:46:23 +00:00
PHP_FALIAS(streammp3, swfmovie_streamMp3, NULL)
PHP_FALIAS(addexport, swfmovie_addExport, NULL)
PHP_FALIAS(writeexports, swfmovie_writeExports, NULL)
PHP_FALIAS(startsound, swfmovie_startSound, NULL)
PHP_FALIAS(stopsound, swfmovie_stopSound, NULL)
PHP_FALIAS(importchar, swfmovie_importChar, NULL)
PHP_FALIAS(importfont, swfmovie_importFont, NULL)
PHP_FALIAS(addfont, swfmovie_addFont, NULL)
#endif
2002-04-08 00:46:23 +00:00
{ NULL, NULL, NULL }
};
2003-06-16 15:12:56 +00:00
/* {{{ proto object swfmovie_init(int version)
Creates swfmovie object according to the passed version */
PHP_FUNCTION(swfmovie_init)
{
2002-04-08 00:46:23 +00:00
zval **version;
SWFMovie movie;
int ret;
if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &version) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(version);
movie = newSWFMovie(Z_LVAL_PP(version));
} else {
movie = newSWFMovie(4); /* default version 4 */
}
ret = zend_list_insert(movie, le_swfmoviep);
object_init_ex(getThis(), movie_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "movie", ret);
zend_list_addref(ret);
}
2001-07-31 05:44:11 +00:00
static void destroy_SWFMovie_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFMovie((SWFMovie)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ getMovie
*/
static SWFMovie getMovie(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *movie = SWFgetProperty(id, "movie", 5, le_swfmoviep TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!movie) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFMovie");
2002-04-08 00:46:23 +00:00
}
return (SWFMovie)movie;
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_nextframe(void)
2002-04-08 00:46:23 +00:00
*/
PHP_FUNCTION(swfmovie_nextFrame)
{
2002-04-08 00:46:23 +00:00
SWFMovie_nextFrame(getMovie(getThis() TSRMLS_CC));
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_labelframe(string label)
Labels frame */
PHP_FUNCTION(swfmovie_labelFrame)
{
2002-04-08 00:46:23 +00:00
zval **label;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &label) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(label);
SWFMovie_labelFrame(getMovie(getThis() TSRMLS_CC), Z_STRVAL_PP(label));
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto object swfmovie_add(object SWFBlock)
2002-04-08 00:46:23 +00:00
*/
PHP_FUNCTION(swfmovie_add)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
int ret;
SWFBlock block;
SWFDisplayItem item;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
2002-04-08 00:46:23 +00:00
/* XXX - SWFMovie_add deals w/ all block types. Probably will need to add that.. */
if (Z_OBJCE_PP(zchar) == action_class_entry_ptr) {
2002-04-08 00:46:23 +00:00
block = (SWFBlock) getAction(*zchar TSRMLS_CC);
} else {
block = (SWFBlock) getCharacter(*zchar TSRMLS_CC);
}
2002-04-08 00:46:23 +00:00
item = SWFMovie_add(movie, block);
if (item != NULL) {
2002-04-08 00:46:23 +00:00
/* try and create a displayitem object */
ret = zend_list_insert(item, le_swfdisplayitemp);
object_init_ex(return_value, displayitem_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(return_value, "displayitem", ret);
}
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_labelframe(object SWFBlock)
2002-04-08 00:46:23 +00:00
*/
PHP_FUNCTION(swfmovie_remove)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
SWFDisplayItem item;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
item = getDisplayItem(*zchar TSRMLS_CC);
SWFMovie_remove(movie, item);
}
/* }}} */
/* {{{ proto int swfmovie_output([int compression])
2002-04-08 00:46:23 +00:00
*/
static void phpByteOutputMethod(byte b, void *data)
{
TSRMLS_FETCH();
php_write(&b, 1 TSRMLS_CC);
}
PHP_FUNCTION(swfmovie_output)
{
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
#ifdef HAVE_MING_ZLIB
2003-08-11 01:54:45 +00:00
zval **zlimit = NULL;
int limit = -1;
if (zend_get_parameters_ex(1, &zlimit) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(zlimit);
limit = Z_LVAL_PP(zlimit);
if ((limit < 0) || (limit > 9)) {
php_error(E_WARNING,"compression level must be within 0..9");
RETURN_FALSE;
}
#endif
#ifdef HAVE_NEW_MING
RETURN_LONG(SWFMovie_output(movie, &phpByteOutputMethod, NULL, limit));
#else
RETURN_LONG(SWFMovie_output(movie, &phpByteOutputMethod, NULL));
#endif
}
/* }}} */
/* {{{ proto int swfmovie_saveToFile(stream x [, int compression])
2002-04-08 00:46:23 +00:00
*/
static void phpStreamOutputMethod(byte b, void * data)
{
2002-04-07 22:43:17 +00:00
TSRMLS_FETCH();
2002-03-15 21:03:08 +00:00
php_stream_write((php_stream*)data, &b, 1);
}
PHP_FUNCTION(swfmovie_saveToFile)
{
2002-04-08 00:46:23 +00:00
zval **x;
2003-08-11 01:54:45 +00:00
#ifdef HAVE_MING_ZLIB
zval **zlimit = NULL;
int limit = -1;
#endif
2002-04-08 00:46:23 +00:00
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
php_stream *what;
switch (ZEND_NUM_ARGS()) {
case 1:
if (zend_get_parameters_ex(1, &x) == FAILURE)
WRONG_PARAM_COUNT;
break;
case 2:
#ifdef HAVE_MING_ZLIB
if (zend_get_parameters_ex(2, &x, &zlimit) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_long_ex(zlimit);
limit = Z_LVAL_PP(zlimit);
if ((limit < 0) || (limit > 9)) {
php_error(E_WARNING,"compression level must be within 0..9");
RETURN_FALSE;
}
#endif
break;
default:
2002-04-08 00:46:23 +00:00
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(what, php_stream *, x, -1,"File-Handle",php_file_le_stream());
#ifdef HAVE_NEW_MING
RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what, limit));
#else
RETURN_LONG(SWFMovie_output(movie, &phpStreamOutputMethod, what));
#endif
}
/* }}} */
/* {{{ proto int swfmovie_save(mixed where [, int compression])
2003-06-16 15:12:56 +00:00
Saves the movie. 'where' can be stream and the movie will be saved there otherwise it is treated as string and written in file with that name */
PHP_FUNCTION(swfmovie_save)
{
2003-08-10 20:39:19 +00:00
zval **x;
2003-08-11 01:54:45 +00:00
#ifdef HAVE_MING_ZLIB
zval **zlimit = NULL;
int limit = -1;
#endif
2002-04-08 00:46:23 +00:00
long retval;
php_stream *stream;
switch (ZEND_NUM_ARGS()) {
case 1:
if (zend_get_parameters_ex(1, &x) == FAILURE) {
WRONG_PARAM_COUNT;
}
break;
case 2:
#ifdef HAVE_MING_ZLIB
if (zend_get_parameters_ex(2, &x, &zlimit) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(zlimit);
limit = Z_LVAL_PP(zlimit);
if ((limit < 0) || (limit > 9)) {
php_error(E_WARNING,"compression level must be within 0..9");
RETURN_FALSE;
}
#endif
break;
default:
2002-04-08 00:46:23 +00:00
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
if (Z_TYPE_PP(x) == IS_RESOURCE) {
ZEND_FETCH_RESOURCE(stream, php_stream *, x, -1,"File-Handle",php_file_le_stream());
#ifdef HAVE_NEW_MING
RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream, limit));
#else
RETURN_LONG(SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, stream));
#endif
2002-04-08 00:46:23 +00:00
}
2002-04-08 00:46:23 +00:00
convert_to_string_ex(x);
stream = php_stream_open_wrapper(Z_STRVAL_PP(x), "wb", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL);
2002-04-08 00:46:23 +00:00
if (stream == NULL) {
RETURN_FALSE;
}
#ifdef HAVE_NEW_MING
retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, (void *)stream, limit);
#else
retval = SWFMovie_output(getMovie(getThis() TSRMLS_CC), &phpStreamOutputMethod, (void *)stream);
#endif
2002-04-08 00:46:23 +00:00
php_stream_close(stream);
RETURN_LONG(retval);
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_setBackground(int r, int g, int b)
Sets background color (r,g,b) */
PHP_FUNCTION(swfmovie_setBackground)
{
2002-04-08 00:46:23 +00:00
zval **r, **g, **b;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
SWFMovie_setBackground(movie, Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b));
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_setRate(float rate)
Sets movie rate */
PHP_FUNCTION(swfmovie_setRate)
{
2002-04-08 00:46:23 +00:00
zval **rate;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &rate) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(rate);
2002-11-12 15:09:44 +00:00
SWFMovie_setRate(movie, FLOAT_Z_DVAL_PP(rate));
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_setDimension(float x, float y)
Sets movie dimension */
PHP_FUNCTION(swfmovie_setDimension)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFMovie_setDimension(movie, FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_setFrames(int frames)
Sets number of frames */
PHP_FUNCTION(swfmovie_setFrames)
{
2002-04-08 00:46:23 +00:00
zval **frames;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &frames) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_long_ex(frames);
SWFMovie_setNumberOfFrames(movie, Z_LVAL_PP(frames));
}
/* }}} */
#ifdef HAVE_NEW_MING
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfmovie_streamMp3(mixed file)
Sets sound stream of the SWF movie. The parameter can be stream or string. */
PHP_FUNCTION(swfmovie_streamMp3)
{
2002-04-08 00:46:23 +00:00
zval **zfile;
SWFSoundStream sound;
2002-04-08 00:46:23 +00:00
SWFInput input;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfile) == FAILURE) {
WRONG_PARAM_COUNT;
}
if (Z_TYPE_PP(zfile) != IS_RESOURCE) {
convert_to_string_ex(zfile);
input = newSWFInput_buffer(Z_STRVAL_PP(zfile), Z_STRLEN_PP(zfile));
zend_list_addref(zend_list_insert(input, le_swfinputp));
} else {
input = getInput(zfile TSRMLS_CC);
}
sound = newSWFSoundStream_fromInput(input);
2002-04-08 00:46:23 +00:00
SWFMovie_setSoundStream(movie, sound);
}
/* }}} */
/* {{{ swfmovie_addexport */
PHP_FUNCTION(swfmovie_addExport)
{
zval **zchar, **zname;
SWFBlock block;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &zchar, &zname) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_object_ex(zchar);
convert_to_string_ex(zname);
block = (SWFBlock)getCharacter(*zchar TSRMLS_CC);
SWFMovie_addExport(movie, block, Z_STRVAL_PP(zname));
}
/* }}} */
/* {{{ swfmovie_writeexports */
PHP_FUNCTION(swfmovie_writeExports)
{
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
SWFMovie_writeExports(movie);
}
/* }}} */
/* {{{ SWFSoundInstance swfmovie_startsound */
PHP_FUNCTION(swfmovie_startSound)
{
zval **zsound;
int ret;
SWFSound sound;
SWFSoundInstance item;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_object_ex(zsound);
sound = (SWFSound)getSound(*zsound TSRMLS_CC);
item = SWFMovie_startSound(movie, sound);
if(item != NULL)
{
/* try and create a soundinstance object */
ret = zend_list_insert(item, le_swfsoundinstancep);
object_init_ex(return_value, soundinstance_class_entry_ptr);
add_property_resource(return_value, "soundinstance", ret);
}
}
/* }}} */
/* {{{ void swfmovie_stopsound */
PHP_FUNCTION(swfmovie_stopSound)
{
zval **zsound;
SWFSound sound;
SWFMovie movie = getMovie(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_object_ex(zsound);
sound = (SWFSound)getSound(*zsound TSRMLS_CC);
SWFMovie_stopSound(movie, sound);
}
/* }}} */
/* {{{ void swfmovie_importChar */
PHP_FUNCTION(swfmovie_importChar)
{
SWFMovie movie;
SWFCharacter res;
int ret;
zval **libswf, **name;
if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &libswf, &name) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(libswf);
convert_to_string_ex(name);
movie = getMovie(getThis() TSRMLS_CC);
res = SWFMovie_importCharacter(movie, Z_STRVAL_PP(libswf), Z_STRVAL_PP(name));
if(res != NULL)
{
/* try and create a sprite object */
ret = zend_list_insert(res, le_swfspritep);
object_init_ex(return_value, sprite_class_entry_ptr);
add_property_resource(return_value, "sprite", ret);
}
}
/* }}} */
/* {{{ void swfmovie_importFont */
PHP_FUNCTION(swfmovie_importFont)
{
SWFMovie movie;
SWFFontCharacter res;
int ret;
zval **libswf, **name;
if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &libswf, &name) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(libswf);
convert_to_string_ex(name);
movie = getMovie(getThis() TSRMLS_CC);
PHP_MING_FILE_CHK(Z_STRVAL_PP(libswf));
res = SWFMovie_importFont(movie, Z_STRVAL_PP(libswf), Z_STRVAL_PP(name));
if(res != NULL)
{
/* try and create a fontchar object */
ret = zend_list_insert(res, le_swffontcharp);
object_init_ex(return_value, fontchar_class_entry_ptr);
add_property_resource(return_value, "fontcharacter", ret);
}
}
/* }}} */
/* {{{ void swfmovie_addFont */
PHP_FUNCTION(swfmovie_addFont)
{
SWFMovie movie;
SWFFontCharacter res;
int ret;
SWFFont font;
zval **zfont;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfont) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_object_ex(zfont);
movie = getMovie(getThis() TSRMLS_CC);
font = getFont(*zfont TSRMLS_CC);
res = SWFMovie_addFont(movie, font);
if(res != NULL)
{
/* try and create a fontchar object */
ret = zend_list_insert(res, le_swffontcharp);
object_init_ex(return_value, fontchar_class_entry_ptr);
add_property_resource(return_value, "fontcharacter", ret);
}
}
/* }}} */
/* }}} */
#endif
2002-04-08 00:46:23 +00:00
/* {{{ SWFShape
*/
static zend_function_entry swfshape_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swfshape, swfshape_init, NULL)
PHP_FALIAS(setline, swfshape_setline, NULL)
PHP_FALIAS(addfill, swfshape_addfill, NULL)
PHP_FALIAS(setleftfill, swfshape_setleftfill, NULL)
PHP_FALIAS(setrightfill, swfshape_setrightfill, NULL)
PHP_FALIAS(movepento, swfshape_movepento, NULL)
PHP_FALIAS(movepen, swfshape_movepen, NULL)
PHP_FALIAS(drawlineto, swfshape_drawlineto, NULL)
PHP_FALIAS(drawline, swfshape_drawline, NULL)
PHP_FALIAS(drawcurveto, swfshape_drawcurveto, NULL)
PHP_FALIAS(drawcurve, swfshape_drawcurve, NULL)
PHP_FALIAS(drawglyph, swfshape_drawglyph, NULL)
PHP_FALIAS(drawcircle, swfshape_drawcircle, NULL)
PHP_FALIAS(drawarc, swfshape_drawarc, NULL)
PHP_FALIAS(drawcubic, swfshape_drawcubic, NULL)
PHP_FALIAS(drawcubicto, swfshape_drawcubicto, NULL)
{ NULL, NULL, NULL }
};
2003-06-16 15:12:56 +00:00
/* {{{ proto object swfshape_init(void)
Returns a new SWFShape object */
PHP_FUNCTION(swfshape_init)
{
2002-04-08 00:46:23 +00:00
SWFShape shape = newSWFShape();
int ret = zend_list_insert(shape, le_swfshapep);
object_init_ex(getThis(), shape_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "shape", ret);
zend_list_addref(ret);
}
2001-07-31 05:44:11 +00:00
static void destroy_SWFShape_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFShape((SWFShape)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function getShape
Returns the SWFShape object contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFShape getShape(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *shape = SWFgetProperty(id, "shape", 5, le_swfshapep TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!shape) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFShape");
2002-04-08 00:46:23 +00:00
}
2002-04-08 00:46:23 +00:00
return (SWFShape)shape;
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfshape_setline(int width, int r, int g, int b [, int a])
Sets the current line style for this SWFShape */
PHP_FUNCTION(swfshape_setline)
{
2002-04-08 00:46:23 +00:00
zval **w, **r, **g, **b, **a;
if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &w, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else if (ZEND_NUM_ARGS() == 5) {
if (zend_get_parameters_ex(5, &w, &r, &g, &b, &a) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(a);
} else if (ZEND_NUM_ARGS() == 1) {
SWFShape_setLine(getShape(getThis() TSRMLS_CC), 0, 0, 0, 0, 0);
return;
} else {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_long_ex(w);
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
if (ZEND_NUM_ARGS() == 4) {
SWFShape_setLine(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
(unsigned short)Z_LVAL_PP(w), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff
2002-04-08 00:46:23 +00:00
);
} else {
SWFShape_setLine(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
(unsigned short)Z_LVAL_PP(w), BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a)
2002-04-08 00:46:23 +00:00
);
}
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto object swfshape_addfill(mixed arg1, int arg2, [int b [, int a]])
Returns a fill object, for use with swfshape_setleftfill and swfshape_setrightfill. If 1 or 2 parameter(s) is (are) passed first should be object (from gradient class) and the second int (flags). Gradient fill is performed. If 3 or 4 parameters are passed : r, g, b [, a]. Solid fill is performed. */
PHP_FUNCTION(swfshape_addfill)
{
2002-04-08 00:46:23 +00:00
SWFFill fill=NULL;
int ret;
if (ZEND_NUM_ARGS() == 1 || ZEND_NUM_ARGS() == 2) {
/* it's a gradient or bitmap */
zval **arg1;
unsigned char flags = 0;
if (ZEND_NUM_ARGS() == 2) {
zval **arg2;
if (zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(arg2);
flags = (unsigned char)Z_LVAL_PP(arg2);
} else {
if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
}
convert_to_object_ex(arg1);
if (Z_OBJCE_PP(arg1) == gradient_class_entry_ptr) {
2002-04-08 00:46:23 +00:00
if (flags == 0) {
flags = SWFFILL_LINEAR_GRADIENT;
}
fill = SWFShape_addGradientFill(getShape(getThis() TSRMLS_CC), getGradient(*arg1 TSRMLS_CC), flags);
} else if (Z_OBJCE_PP(arg1) == bitmap_class_entry_ptr) {
2002-04-08 00:46:23 +00:00
if (flags == 0) {
flags = SWFFILL_TILED_BITMAP;
}
fill = SWFShape_addBitmapFill(getShape(getThis() TSRMLS_CC), getBitmap(*arg1 TSRMLS_CC), flags);
} else {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Argument is not a bitmap nor a gradient");
2002-04-08 00:46:23 +00:00
}
} else if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) {
/* it's a solid fill */
zval **r, **g, **b, **za;
2002-11-12 15:09:44 +00:00
byte a = 0xff;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() == 3) {
if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
2002-04-08 00:46:23 +00:00
WRONG_PARAM_COUNT;
}
} else if (ZEND_NUM_ARGS() == 4) {
2002-04-08 00:46:23 +00:00
if (zend_get_parameters_ex(4, &r, &g, &b, &za) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(za);
2002-11-12 15:09:44 +00:00
a = BYTE_Z_LVAL_PP(za);
2002-04-08 00:46:23 +00:00
} else {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC),
BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), a
);
2002-04-08 00:46:23 +00:00
} else {
WRONG_PARAM_COUNT;
}
if (!fill) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error adding fill to shape");
2002-04-08 00:46:23 +00:00
}
2002-04-08 00:46:23 +00:00
/* return an SWFFill object */
ret = zend_list_insert(fill, le_swffillp);
object_init_ex(return_value, fill_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(return_value, "fill", ret);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfshape_setleftfill(int arg1 [, int g ,int b [,int a]])
Sets the left side fill style to fill in case only one parameter is passed. When 3 or 4 parameters are passed they are treated as : int r, int g, int b, int a . Solid fill is performed in this case before setting left side fill type. */
PHP_FUNCTION(swfshape_setleftfill)
{
2002-04-08 00:46:23 +00:00
zval **zfill, **r, **g, **b, **a;
SWFFill fill;
if (ZEND_NUM_ARGS() == 3) {
if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff
2002-04-08 00:46:23 +00:00
);
} else if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
convert_to_long_ex(a);
fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a)
2002-04-08 00:46:23 +00:00
);
} else if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &zfill) == FAILURE) {
WRONG_PARAM_COUNT;
}
if (Z_LVAL_PP(zfill) != 0) {
convert_to_object_ex(zfill);
fill = getFill(*zfill TSRMLS_CC);
} else {
fill = NULL;
}
} else {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
SWFShape_setLeftFill(getShape(getThis() TSRMLS_CC), fill);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfshape_setleftfill(int arg1 [, int g ,int b [,int a]])
Sets the right side fill style to fill in case only one parameter is passed. When 3 or 4 parameters are passed they are treated as : int r, int g, int b, int a . Solid fill is performed in this case before setting right side fill type. */
PHP_FUNCTION(swfshape_setrightfill)
{
2002-04-08 00:46:23 +00:00
zval **zfill, **r, **g, **b, **a;
SWFFill fill;
if (ZEND_NUM_ARGS() == 3) {
if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff
2002-04-08 00:46:23 +00:00
);
} else if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
convert_to_long_ex(a);
fill = SWFShape_addSolidFill(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a)
2002-04-08 00:46:23 +00:00
);
} else if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &zfill) == FAILURE) {
2002-04-08 00:46:23 +00:00
WRONG_PARAM_COUNT;
}
if (Z_LVAL_PP(zfill) != 0) {
convert_to_object_ex(zfill);
fill = getFill(*zfill TSRMLS_CC);
} else {
fill = NULL;
}
} else {
WRONG_PARAM_COUNT;
}
SWFShape_setRightFill(getShape(getThis() TSRMLS_CC), fill);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swfshape_movepento(float x, float y)
2001-10-09 05:30:21 +00:00
Moves the pen to shape coordinates (x, y) */
PHP_FUNCTION(swfshape_movepento)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFShape_movePenTo(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swfshape_movepen(float x, float y)
2001-10-09 05:30:21 +00:00
Moves the pen from its current location by vector (x, y) */
PHP_FUNCTION(swfshape_movepen)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFShape_movePen(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swfshape_drawlineto(float x, float y)
2001-10-09 05:30:21 +00:00
Draws a line from the current pen position to shape coordinates (x, y) in the current line style */
PHP_FUNCTION(swfshape_drawlineto)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFShape_drawLineTo(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swfshape_drawline(float dx, float dy)
2001-10-09 05:30:21 +00:00
Draws a line from the current pen position (x, y) to the point (x+dx, y+dy) in the current line style */
PHP_FUNCTION(swfshape_drawline)
2002-04-08 00:46:23 +00:00
{
zval **x, **y;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFShape_drawLine(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swfshape_drawcurveto(float ax, float ay, float bx, float by [, float dx, float dy])
2001-10-09 05:30:21 +00:00
Draws a curve from the current pen position (x,y) to the point (bx, by) in the current line style, using point (ax, ay) as a control point. Or draws a cubic bezier to point (dx, dy) with control points (ax, ay) and (bx, by) */
PHP_FUNCTION(swfshape_drawcurveto)
{
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() == 4) {
zval **cx, **cy, **ax, **ay;
if (zend_get_parameters_ex(4, &cx, &cy, &ax, &ay) == FAILURE) {
2002-04-08 00:46:23 +00:00
WRONG_PARAM_COUNT;
}
convert_to_double_ex(cx);
convert_to_double_ex(cy);
convert_to_double_ex(ax);
convert_to_double_ex(ay);
2002-04-08 00:46:23 +00:00
SWFShape_drawCurveTo(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(ax), FLOAT_Z_DVAL_PP(ay)
2002-04-08 00:46:23 +00:00
);
} else if (ZEND_NUM_ARGS() == 6) {
zval **bx, **by, **cx, **cy, **dx, **dy;
if (zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(bx);
convert_to_double_ex(by);
convert_to_double_ex(cx);
convert_to_double_ex(cy);
convert_to_double_ex(dx);
convert_to_double_ex(dy);
RETURN_LONG(SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy))
2002-04-08 00:46:23 +00:00
);
} else {
WRONG_PARAM_COUNT;
}
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfshape_drawcurve(float adx, float ady, float bdx, float bdy [, float cdx, float cdy])
Draws a curve from the current pen position (x, y) to the point (x+bdx, y+bdy) in the current line style, using point (x+adx, y+ady) as a control point or draws a cubic bezier to point (x+cdx, x+cdy) with control points (x+adx, y+ady) and (x+bdx, y+bdy) */
PHP_FUNCTION(swfshape_drawcurve)
{
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() == 4) {
zval **cx, **cy, **ax, **ay;
if (zend_get_parameters_ex(4, &cx, &cy, &ax, &ay) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(cx);
convert_to_double_ex(cy);
convert_to_double_ex(ax);
convert_to_double_ex(ay);
SWFShape_drawCurve(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(ax), FLOAT_Z_DVAL_PP(ay)
2002-04-08 00:46:23 +00:00
);
} else if (ZEND_NUM_ARGS() == 6) {
2002-04-08 00:46:23 +00:00
zval **bx, **by, **cx, **cy, **dx, **dy;
if (zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(bx);
convert_to_double_ex(by);
convert_to_double_ex(cx);
convert_to_double_ex(cy);
convert_to_double_ex(dx);
convert_to_double_ex(dy);
RETURN_LONG( SWFShape_drawCubic(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy))
2002-04-08 00:46:23 +00:00
);
} else {
WRONG_PARAM_COUNT;
}
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swfshape_drawglyph(SWFFont font, string character [, int size])
2001-10-09 05:30:21 +00:00
Draws the first character in the given string into the shape using the glyph definition from the given font */
PHP_FUNCTION(swfshape_drawglyph)
{
2002-04-08 00:46:23 +00:00
zval **font, **c, **zsize;
int size=0;
if (ZEND_NUM_ARGS() == 2) {
if (zend_get_parameters_ex(2, &font, &c) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-11-12 15:09:44 +00:00
size = (int)(1024.0f/Ming_getScale());
2002-04-08 00:46:23 +00:00
} else if (ZEND_NUM_ARGS() == 3) {
if (zend_get_parameters_ex(3, &font, &c, &zsize) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(zsize);
size = Z_LVAL_PP(zsize);
}
convert_to_string_ex(c);
SWFShape_drawSizedGlyph(getShape(getThis() TSRMLS_CC), getFont(*font TSRMLS_CC), Z_STRVAL_PP(c)[0], size);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfshape_drawcircle(float r)
2001-10-09 05:30:21 +00:00
Draws a circle of radius r centered at the current location, in a counter-clockwise fashion */
PHP_FUNCTION(swfshape_drawcircle)
{
2002-04-08 00:46:23 +00:00
zval **r;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &r) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(r);
2002-11-12 15:09:44 +00:00
SWFShape_drawCircle(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfshape_drawarc(float r, float startAngle, float endAngle)
2001-10-09 05:30:21 +00:00
Draws an arc of radius r centered at the current location, from angle startAngle to angle endAngle measured counterclockwise from 12 o'clock */
PHP_FUNCTION(swfshape_drawarc)
{
2002-04-08 00:46:23 +00:00
zval **r, **start, **end;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &r, &start, &end) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(r);
convert_to_double_ex(start);
convert_to_double_ex(end);
2002-04-08 00:46:23 +00:00
/* convert angles to radians, since that's what php uses elsewhere */
2002-11-12 15:09:44 +00:00
SWFShape_drawArc(getShape(getThis() TSRMLS_CC), FLOAT_Z_DVAL_PP(r), (float)(Z_DVAL_PP(start)*M_PI/180.0), (float)(Z_DVAL_PP(end)*M_PI/180.0));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swfshape_drawcubic(float bx, float by, float cx, float cy, float dx, float dy)
2001-10-09 05:30:21 +00:00
Draws a cubic bezier curve using the current position and the three given points as control points */
PHP_FUNCTION(swfshape_drawcubic)
{
2002-04-08 00:46:23 +00:00
zval **bx, **by, **cx, **cy, **dx, **dy;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(bx);
convert_to_double_ex(by);
convert_to_double_ex(cx);
convert_to_double_ex(cy);
convert_to_double_ex(dx);
convert_to_double_ex(dy);
2002-04-08 00:46:23 +00:00
RETURN_LONG( SWFShape_drawCubic(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy))
2002-04-08 00:46:23 +00:00
);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swfshape_drawcubic(float bx, float by, float cx, float cy, float dx, float dy)
2001-10-09 05:30:21 +00:00
Draws a cubic bezier curve using the current position and the three given points as control points */
PHP_FUNCTION(swfshape_drawcubicto)
{
2002-04-08 00:46:23 +00:00
zval **bx, **by, **cx, **cy, **dx, **dy;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &bx, &by, &cx, &cy, &dx, &dy) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(bx);
convert_to_double_ex(by);
convert_to_double_ex(cx);
convert_to_double_ex(cy);
convert_to_double_ex(dx);
convert_to_double_ex(dy);
2002-04-08 00:46:23 +00:00
RETURN_LONG( SWFShape_drawCubicTo(getShape(getThis() TSRMLS_CC),
2002-11-12 15:09:44 +00:00
FLOAT_Z_DVAL_PP(bx), FLOAT_Z_DVAL_PP(by), FLOAT_Z_DVAL_PP(cx), FLOAT_Z_DVAL_PP(cy), FLOAT_Z_DVAL_PP(dx), FLOAT_Z_DVAL_PP(dy))
2002-04-08 00:46:23 +00:00
);
}
/* }}} */
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFSprite
*/
static zend_function_entry swfsprite_functions[] = {
PHP_FALIAS(swfsprite, swfsprite_init, NULL)
PHP_FALIAS(add, swfsprite_add, NULL)
PHP_FALIAS(remove, swfsprite_remove, NULL)
PHP_FALIAS(nextframe, swfsprite_nextFrame, NULL)
PHP_FALIAS(labelframe, swfsprite_labelFrame, NULL)
PHP_FALIAS(setframes, swfsprite_setFrames, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(startsound, swfsprite_startSound, NULL)
PHP_FALIAS(stopsound, swfsprite_stopSound, NULL)
#endif
2002-04-08 00:46:23 +00:00
{ NULL, NULL, NULL }
};
2001-10-09 05:30:21 +00:00
/* {{{ proto class swfsprite_init(void)
Returns a new SWFSprite object */
PHP_FUNCTION(swfsprite_init)
{
2002-04-08 00:46:23 +00:00
SWFMovieClip sprite = newSWFMovieClip();
int ret = zend_list_insert(sprite, le_swfspritep);
object_init_ex(getThis(), sprite_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "sprite", ret);
zend_list_addref(ret);
}
2001-07-31 05:44:11 +00:00
static void destroy_SWFSprite_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFMovieClip((SWFMovieClip)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function SWFSprite getSprite(zval *id)
Returns the SWFSprite object in zval *id */
2002-04-08 00:46:23 +00:00
static SWFMovieClip getSprite(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *sprite = SWFgetProperty(id, "sprite", 6, le_swfspritep TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!sprite) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFSprite");
2002-04-08 00:46:23 +00:00
}
return (SWFMovieClip)sprite;
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto object swfsprite_add(object SWFCharacter)
2002-07-14 15:45:33 +00:00
Adds the character to the sprite, returns a displayitem object */
PHP_FUNCTION(swfsprite_add)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
int ret;
SWFBlock block;
SWFDisplayItem item;
SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
if (Z_OBJCE_PP(zchar) == action_class_entry_ptr) {
2002-04-08 00:46:23 +00:00
block = (SWFBlock)getAction(*zchar TSRMLS_CC);
} else {
block = (SWFBlock)getCharacter(*zchar TSRMLS_CC);
}
2002-04-08 00:46:23 +00:00
item = SWFMovieClip_add(sprite, block);
2002-04-08 00:46:23 +00:00
if (item != NULL) {
/* try and create a displayitem object */
ret = zend_list_insert(item, le_swfdisplayitemp);
object_init_ex(return_value, displayitem_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(return_value, "displayitem", ret);
}
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfsprite_remove(object SWFDisplayItem)
Remove the named character from the sprite's display list */
PHP_FUNCTION(swfsprite_remove)
{
2002-04-08 00:46:23 +00:00
zval **zchar;
SWFDisplayItem item;
SWFMovieClip movie = getSprite(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zchar) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zchar);
item = getDisplayItem(*zchar TSRMLS_CC);
SWFMovieClip_remove(movie, item);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swfsprite_nextFrame(void)
Moves the sprite to the next frame */
PHP_FUNCTION(swfsprite_nextFrame)
{
2002-04-08 00:46:23 +00:00
SWFMovieClip_nextFrame(getSprite(getThis() TSRMLS_CC));
}
/* }}} */
2003-06-16 15:12:56 +00:00
/* {{{ proto void swfsprite_labelFrame(string label)
Labels frame */
PHP_FUNCTION(swfsprite_labelFrame)
{
2002-04-08 00:46:23 +00:00
zval **label;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &label) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(label);
SWFMovieClip_labelFrame(getSprite(getThis() TSRMLS_CC), Z_STRVAL_PP(label));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swfsprite_setFrames(int frames)
Sets the number of frames in this SWFSprite */
PHP_FUNCTION(swfsprite_setFrames)
{
2002-04-08 00:46:23 +00:00
zval **frames;
SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &frames) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(frames);
SWFMovieClip_setNumberOfFrames(sprite, Z_LVAL_PP(frames));
}
/* }}} */
#ifdef HAVE_NEW_MING
/* {{{ SWFSoundInstance swfsprite_startsound */
PHP_FUNCTION(swfsprite_startSound)
{
zval **zsound;
int ret;
SWFSound sound;
SWFSoundInstance item;
SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_object_ex(zsound);
sound = (SWFSound)getSound(*zsound TSRMLS_CC);
item = SWFMovieClip_startSound(sprite, sound);
if(item != NULL) {
/* try and create a displayitem object */
ret = zend_list_insert(item, le_swfsoundinstancep);
object_init_ex(return_value, soundinstance_class_entry_ptr);
add_property_resource(return_value, "soundinstance", ret);
}
}
/* }}} */
/* {{{ void swfsprite_stopsound */
PHP_FUNCTION(swfsprite_stopSound)
{
zval **zsound;
SWFSound sound;
SWFMovieClip sprite = getSprite(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zsound) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_object_ex(zsound);
sound = (SWFSound)getSound(*zsound TSRMLS_CC);
SWFMovieClip_stopSound(sprite, sound);
}
/* }}} */
#endif
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFText
*/
static zend_function_entry swftext_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swftext, swftext_init, NULL)
PHP_FALIAS(setfont, swftext_setFont, NULL)
PHP_FALIAS(setheight, swftext_setHeight, NULL)
PHP_FALIAS(setspacing, swftext_setSpacing, NULL)
PHP_FALIAS(setcolor, swftext_setColor, NULL)
PHP_FALIAS(moveto, swftext_moveTo, NULL)
PHP_FALIAS(addstring, swftext_addString, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(addutf8string, swftext_addUTF8String, NULL)
/* PHP_FALIAS(addwidestring, swftext_addWideString, NULL)*/
#endif
2002-04-08 00:46:23 +00:00
PHP_FALIAS(getwidth, swftext_getWidth, NULL)
#ifdef HAVE_NEW_MING
PHP_FALIAS(getutf8width, swftext_getUTF8Width, NULL)
/* PHP_FALIAS(getwidewidth, swftext_getWideWidth, NULL)*/
#endif
2002-04-08 00:46:23 +00:00
PHP_FALIAS(getascent, swftext_getAscent, NULL)
PHP_FALIAS(getdescent, swftext_getDescent, NULL)
PHP_FALIAS(getleading, swftext_getLeading, NULL)
{ NULL, NULL, NULL }
};
/* {{{ proto class swftext_init(void)
Returns new SWFText object */
PHP_FUNCTION(swftext_init)
{
2002-04-08 00:46:23 +00:00
SWFText text = newSWFText2();
int ret = zend_list_insert(text, le_swftextp);
object_init_ex(getThis(), text_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "text", ret);
zend_list_addref(ret);
}
2001-07-31 05:44:11 +00:00
static void destroy_SWFText_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFText((SWFText)resource->ptr);
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ internal function SWFText getText(zval *id)
Returns the SWFText contained in zval *id */
2002-04-08 00:46:23 +00:00
static SWFText getText(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *text = SWFgetProperty(id, "text", 4, le_swftextp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!text) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFText");
2002-04-08 00:46:23 +00:00
}
return (SWFText)text;
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swftext_setFont(object font)
Sets this SWFText object's current font to given font */
PHP_FUNCTION(swftext_setFont)
{
2002-04-08 00:46:23 +00:00
zval **zfont;
SWFText text = getText(getThis() TSRMLS_CC);
SWFFont font;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zfont) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(zfont);
font = getFont(*zfont TSRMLS_CC);
SWFText_setFont(text, font);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swftext_setHeight(float height)
Sets this SWFText object's current height to given height */
PHP_FUNCTION(swftext_setHeight)
{
2002-04-08 00:46:23 +00:00
zval **height;
SWFText text = getText(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &height) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(height);
2002-11-12 15:09:44 +00:00
SWFText_setHeight(text, FLOAT_Z_DVAL_PP(height));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swftext_setSpacing(float spacing)
Sets this SWFText object's current letterspacing to given spacing */
PHP_FUNCTION(swftext_setSpacing)
{
2002-04-08 00:46:23 +00:00
zval **spacing;
SWFText text = getText(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &spacing) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(spacing);
2002-11-12 15:09:44 +00:00
SWFText_setSpacing(text, FLOAT_Z_DVAL_PP(spacing));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swftext_setColor(int r, int g, int b [, int a])
Sets this SWFText object's current color to the given color */
PHP_FUNCTION(swftext_setColor)
{
2002-04-08 00:46:23 +00:00
zval **r, **g, **b, **a;
SWFText text = getText(getThis() TSRMLS_CC);
if (ZEND_NUM_ARGS() == 3) {
if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(a);
} else {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
if (ZEND_NUM_ARGS() == 4) {
2002-11-12 15:09:44 +00:00
SWFText_setColor(text, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), BYTE_Z_LVAL_PP(a));
2002-04-08 00:46:23 +00:00
} else {
2002-11-12 15:09:44 +00:00
SWFText_setColor(text, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), 0xff);
2002-04-08 00:46:23 +00:00
}
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swftext_moveTo(float x, float y)
2001-10-09 05:30:21 +00:00
Moves this SWFText object's current pen position to (x, y) in text coordinates */
PHP_FUNCTION(swftext_moveTo)
{
2002-04-08 00:46:23 +00:00
zval **x, **y;
SWFText text = getText(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(x);
convert_to_double_ex(y);
2002-11-12 15:09:44 +00:00
SWFText_setXY(text, FLOAT_Z_DVAL_PP(x), FLOAT_Z_DVAL_PP(y));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swftext_addString(string text)
2001-10-09 05:30:21 +00:00
Writes the given text into this SWFText object at the current pen position, using the current font, height, spacing, and color */
PHP_FUNCTION(swftext_addString)
{
2002-04-08 00:46:23 +00:00
zval **s;
SWFText text = getText(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE) {
WRONG_PARAM_COUNT;
}
2002-04-08 00:46:23 +00:00
convert_to_string_ex(s);
SWFText_addString(text, Z_STRVAL_PP(s), NULL);
}
/* }}} */
2002-04-08 00:46:23 +00:00
#ifdef HAVE_NEW_MING
/* {{{ proto void swftext_addUTF8String(string text)
Writes the given text into this SWFText object at the current pen position,
using the current font, height, spacing, and color */
PHP_FUNCTION(swftext_addUTF8String)
{
zval **s;
SWFText text = getText(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(s);
SWFText_addUTF8String(text, Z_STRVAL_PP(s), NULL);
}
/* }}} */
/* {{{ proto void swftext_addWideString(string text)
Writes the given text into this SWFText object at the current pen position,
using the current font, height, spacing, and color */
/*
PHP_FUNCTION(swftext_addWideString)
{
zval **s;
SWFText text = getText(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &s) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(s);
SWFText_addWideString(text, Z_STRVAL_PP(s), NULL);
}
*/
/* }}} */
#endif
2001-10-09 05:30:21 +00:00
/* {{{ proto float swftext_getWidth(string str)
Calculates the width of the given string in this text objects current font and size */
PHP_FUNCTION(swftext_getWidth)
{
2002-04-08 00:46:23 +00:00
zval **zstring;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(zstring);
2002-11-12 15:09:44 +00:00
RETURN_DOUBLE(SWFText_getStringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring)));
}
/* }}} */
2002-04-08 00:46:23 +00:00
#ifdef HAVE_NEW_MING
/* {{{ proto double swftext_getUTF8Width(string)
calculates the width of the given string in this text objects current font and size */
PHP_FUNCTION(swftext_getUTF8Width)
{
zval **zstring;
int width;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
width = SWFText_getUTF8StringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
RETURN_DOUBLE(width);
}
/* }}} */
/* {{{ proto double swftext_getWideWidth(string)
calculates the width of the given string in this text objects current font and size */
/*
PHP_FUNCTION(swftext_getWideWidth)
{
zval **zstring;
int width;
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
width = SWFText_getWideStringWidth(getText(getThis() TSRMLS_CC), Z_STRVAL_PP(zstring));
RETURN_DOUBLE(width);
}
*/
/* }}} */
#endif
2001-10-09 05:30:21 +00:00
/* {{{ proto float swftext_getAscent(void)
Returns the ascent of the current font at its current size, or 0 if not available */
PHP_FUNCTION(swftext_getAscent)
{
2002-04-08 00:46:23 +00:00
RETURN_DOUBLE(SWFText_getAscent(getText(getThis() TSRMLS_CC)));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto float swftext_getDescent(void)
Returns the descent of the current font at its current size, or 0 if not available */
PHP_FUNCTION(swftext_getDescent)
{
2001-08-07 23:27:01 +00:00
RETURN_DOUBLE(SWFText_getDescent(getText(getThis() TSRMLS_CC)));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto float swftext_getLeading(void)
Returns the leading of the current font at its current size, or 0 if not available */
PHP_FUNCTION(swftext_getLeading)
{
2001-08-07 23:27:01 +00:00
RETURN_DOUBLE(SWFText_getLeading(getText(getThis() TSRMLS_CC)));
}
/* }}} */
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ SWFTextField
*/
static zend_function_entry swftextfield_functions[] = {
2002-04-08 00:46:23 +00:00
PHP_FALIAS(swftextfield, swftextfield_init, NULL)
PHP_FALIAS(setfont, swftextfield_setFont, NULL)
PHP_FALIAS(setbounds, swftextfield_setBounds, NULL)
PHP_FALIAS(align, swftextfield_align, NULL)
PHP_FALIAS(setheight, swftextfield_setHeight, NULL)
PHP_FALIAS(setleftmargin, swftextfield_setLeftMargin, NULL)
PHP_FALIAS(setrightmargin, swftextfield_setRightMargin, NULL)
PHP_FALIAS(setmargins, swftextfield_setMargins, NULL)
PHP_FALIAS(setindentation, swftextfield_setIndentation, NULL)
PHP_FALIAS(setlinespacing, swftextfield_setLineSpacing, NULL)
PHP_FALIAS(setcolor, swftextfield_setColor, NULL)
PHP_FALIAS(setname, swftextfield_setName, NULL)
PHP_FALIAS(addstring, swftextfield_addString, NULL)
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
PHP_FALIAS(setpadding, swftextfield_setPadding, NULL)
PHP_FALIAS(addchars, swftextfield_addChars, NULL)
2003-11-12 09:12:51 +00:00
#endif
2002-04-08 00:46:23 +00:00
{ NULL, NULL, NULL }
};
2002-04-08 00:46:23 +00:00
/* {{{ proto object swftextfield_init([int flags])
2001-10-09 05:30:21 +00:00
Returns a new SWFTextField object */
PHP_FUNCTION(swftextfield_init)
{
2002-04-08 00:46:23 +00:00
zval **flags;
SWFTextField field = newSWFTextField();
int ret = zend_list_insert(field, le_swftextfieldp);
object_init_ex(getThis(), textfield_class_entry_ptr);
2002-04-08 00:46:23 +00:00
add_property_resource(getThis(), "textfield", ret);
zend_list_addref(ret);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() == 1) {
if (zend_get_parameters_ex(1, &flags) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(flags);
SWFTextField_setFlags(field, Z_LVAL_PP(flags));
}
}
/* }}} */
2001-07-31 05:44:11 +00:00
static void destroy_SWFTextField_resource(zend_rsrc_list_entry *resource TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
destroySWFTextField((SWFTextField)resource->ptr);
}
2002-04-08 00:46:23 +00:00
/* {{{ internal function getTextField
Returns the SWFTextField object contained in zval *id */
2001-08-07 23:27:01 +00:00
static SWFTextField getTextField(zval *id TSRMLS_DC)
{
2002-04-08 00:46:23 +00:00
void *field = SWFgetProperty(id, "textfield", 9, le_swftextfieldp TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (!field) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Called object is not an SWFTextField");
2002-04-08 00:46:23 +00:00
}
return (SWFTextField)field;
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swftextfield_setFont(object font)
2001-10-09 05:30:21 +00:00
Sets the font for this textfield */
PHP_FUNCTION(swftextfield_setFont)
{
2002-04-08 00:46:23 +00:00
zval **font;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &font) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_object_ex(font);
SWFTextField_setFont(field, getFont(*font TSRMLS_CC));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swftextfield_setBounds(float width, float height)
2001-10-09 05:30:21 +00:00
Sets the width and height of this textfield */
PHP_FUNCTION(swftextfield_setBounds)
{
2002-04-08 00:46:23 +00:00
zval **width, **height;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &width, &height) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(width);
convert_to_double_ex(height);
2002-11-12 15:09:44 +00:00
SWFTextField_setBounds(field, FLOAT_Z_DVAL_PP(width), FLOAT_Z_DVAL_PP(height));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swftextfield_align(int alignment)
Sets the alignment of this textfield */
PHP_FUNCTION(swftextfield_align)
{
2002-04-08 00:46:23 +00:00
zval **align;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &align) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(align);
SWFTextField_setAlignment(field, Z_LVAL_PP(align));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swftextfield_setHeight(float height)
2001-10-09 05:30:21 +00:00
Sets the font height of this textfield */
PHP_FUNCTION(swftextfield_setHeight)
{
2002-04-08 00:46:23 +00:00
zval **height;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &height) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(height);
2002-11-12 15:09:44 +00:00
SWFTextField_setHeight(field, FLOAT_Z_DVAL_PP(height));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2003-06-16 15:12:56 +00:00
/* {{{ proto void swftextfield_setLeftMargin(float margin)
2001-10-09 05:30:21 +00:00
Sets the left margin of this textfield */
PHP_FUNCTION(swftextfield_setLeftMargin)
{
2002-04-08 00:46:23 +00:00
zval **margin;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &margin) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(margin);
2002-11-12 15:09:44 +00:00
SWFTextField_setLeftMargin(field, FLOAT_Z_DVAL_PP(margin));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swftextfield_setRightMargin(float margin)
Sets the right margin of this textfield */
PHP_FUNCTION(swftextfield_setRightMargin)
{
2002-04-08 00:46:23 +00:00
zval **margin;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &margin) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(margin);
2002-11-12 15:09:44 +00:00
SWFTextField_setRightMargin(field, FLOAT_Z_DVAL_PP(margin));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-09-21 21:59:27 +00:00
/* {{{ proto void swftextfield_setMargins(float left, float right)
2001-10-09 05:30:21 +00:00
Sets both margins of this textfield */
PHP_FUNCTION(swftextfield_setMargins)
{
2002-04-08 00:46:23 +00:00
zval **left, **right;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &left, &right) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(left);
convert_to_double_ex(right);
2002-11-12 15:09:44 +00:00
SWFTextField_setLeftMargin(field, FLOAT_Z_DVAL_PP(left));
SWFTextField_setRightMargin(field, FLOAT_Z_DVAL_PP(right));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swftextfield_setIndentation(float indentation)
Sets the indentation of the first line of this textfield */
PHP_FUNCTION(swftextfield_setIndentation)
{
2002-04-08 00:46:23 +00:00
zval **indent;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &indent) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(indent);
2002-11-12 15:09:44 +00:00
SWFTextField_setIndentation(field, FLOAT_Z_DVAL_PP(indent));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swftextfield_setLineSpacing(float space)
Sets the line spacing of this textfield */
PHP_FUNCTION(swftextfield_setLineSpacing)
{
2002-04-08 00:46:23 +00:00
zval **spacing;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &spacing) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_double_ex(spacing);
2002-11-12 15:09:44 +00:00
SWFTextField_setLineSpacing(field, FLOAT_Z_DVAL_PP(spacing));
}
/* }}} */
2002-04-08 00:46:23 +00:00
/* {{{ proto void swftextfield_setColor(int r, int g, int b [, int a])
2001-10-09 05:30:21 +00:00
Sets the color of this textfield */
PHP_FUNCTION(swftextfield_setColor)
{
2002-04-08 00:46:23 +00:00
zval **r, **g, **b, **a;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-11-12 15:09:44 +00:00
byte alpha = 0xff;
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() == 3) {
if (zend_get_parameters_ex(3, &r, &g, &b) == FAILURE) {
WRONG_PARAM_COUNT;
}
} else if (ZEND_NUM_ARGS() == 4) {
if (zend_get_parameters_ex(4, &r, &g, &b, &a) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(a);
2002-11-12 15:09:44 +00:00
alpha = BYTE_Z_LVAL_PP(a);
2002-04-08 00:46:23 +00:00
} else {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(r);
convert_to_long_ex(g);
convert_to_long_ex(b);
2002-11-12 15:09:44 +00:00
SWFTextField_setColor(field, BYTE_Z_LVAL_PP(r), BYTE_Z_LVAL_PP(g), BYTE_Z_LVAL_PP(b), (byte)alpha);
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swftextfield_setName(string var_name)
Sets the variable name of this textfield */
PHP_FUNCTION(swftextfield_setName)
{
2002-04-08 00:46:23 +00:00
zval **name;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &name) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(name);
SWFTextField_setVariableName(field, Z_STRVAL_PP(name));
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ proto void swftextfield_addString(string str)
Adds the given string to this textfield */
PHP_FUNCTION(swftextfield_addString)
{
2002-04-08 00:46:23 +00:00
zval **string;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
2002-04-08 00:46:23 +00:00
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &string) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(string);
SWFTextField_addString(field, Z_STRVAL_PP(string));
}
/* }}} */
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
/* {{{ proto void swftextfield_setPadding(float padding)
Sets the padding of this textfield */
PHP_FUNCTION(swftextfield_setPadding)
{
zval **padding;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &padding) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_double_ex(padding);
SWFTextField_setPadding(field, Z_DVAL_PP(padding));
}
/* }}} */
/* {{{ proto void swftextfield_addChars(string)
adds characters to a font that will be available within a textfield */
PHP_FUNCTION(swftextfield_addChars)
{
zval **zstring;
SWFTextField field = getTextField(getThis() TSRMLS_CC);
if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &zstring) == FAILURE)
WRONG_PARAM_COUNT;
convert_to_string_ex(zstring);
SWFTextField_addChars(field, Z_STRVAL_PP(zstring));
}
/* }}} */
2003-11-12 09:12:51 +00:00
#endif
2002-04-08 00:46:23 +00:00
zend_module_entry ming_module_entry = {
STANDARD_MODULE_HEADER,
2002-04-08 00:46:23 +00:00
"ming",
ming_functions,
PHP_MINIT(ming), /* module init function */
NULL, /* module shutdown function */
PHP_RINIT(ming), /* request init function */
NULL, /* request shutdown function */
PHP_MINFO(ming), /* module info function */
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_MING
ZEND_GET_MODULE(ming)
#endif
2001-10-09 05:30:21 +00:00
/* {{{ todo PHP_MINFO_FUNCTION(ming)
*/
PHP_MINFO_FUNCTION(ming)
{
2002-04-08 00:46:23 +00:00
php_info_print_table_start();
php_info_print_table_row(2, "Ming SWF output library", "enabled");
2002-04-08 00:46:23 +00:00
php_info_print_table_row(2, "Version", MING_VERSION_TEXT);
php_info_print_table_end();
}
/* }}} */
2002-04-08 00:46:23 +00:00
2001-10-09 05:30:21 +00:00
/* {{{ todo PHP_MINIT_FUNCTION(ming)
*/
2002-11-12 14:18:25 +00:00
/* custom error handler propagates ming errors up to php */
static void php_ming_error(const char *msg, ...)
{
2002-04-08 00:46:23 +00:00
va_list args;
2002-11-12 13:16:13 +00:00
char *buffer;
2002-11-12 14:18:25 +00:00
TSRMLS_FETCH();
2002-04-08 00:46:23 +00:00
va_start(args, msg);
2002-11-12 13:16:13 +00:00
vspprintf(&buffer, 0, msg, args);
2002-04-08 00:46:23 +00:00
va_end(args);
php_error_docref(NULL TSRMLS_CC, E_ERROR, "%s", buffer);
2002-11-12 13:16:13 +00:00
efree(buffer);
}
PHP_RINIT_FUNCTION(ming)
{
2002-04-08 00:46:23 +00:00
/* XXX - this didn't work so well last I tried.. */
2001-08-22 09:20:40 +00:00
2002-04-08 00:46:23 +00:00
if (Ming_init() != 0) {
2002-11-12 13:16:13 +00:00
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error initializing Ming module");
2002-04-08 00:46:23 +00:00
return FAILURE;
}
return SUCCESS;
}
PHP_MINIT_FUNCTION(ming)
{
zend_class_entry shape_class_entry;
zend_class_entry fill_class_entry;
zend_class_entry gradient_class_entry;
zend_class_entry bitmap_class_entry;
zend_class_entry text_class_entry;
zend_class_entry textfield_class_entry;
zend_class_entry font_class_entry;
zend_class_entry displayitem_class_entry;
zend_class_entry movie_class_entry;
zend_class_entry button_class_entry;
zend_class_entry action_class_entry;
zend_class_entry morph_class_entry;
zend_class_entry sprite_class_entry;
zend_class_entry sound_class_entry;
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
zend_class_entry fontchar_class_entry;
zend_class_entry soundinstance_class_entry;
2003-11-12 09:12:51 +00:00
#endif
Ming_setErrorFunction((void *) php_ming_error);
#define CONSTANT(s,c) REGISTER_LONG_CONSTANT((s), (c), CONST_CS | CONST_PERSISTENT)
2002-04-08 00:46:23 +00:00
/* flags for SWFButton_addShape */
CONSTANT("SWFBUTTON_HIT", SWFBUTTONRECORD_HITSTATE);
CONSTANT("SWFBUTTON_DOWN", SWFBUTTONRECORD_DOWNSTATE);
CONSTANT("SWFBUTTON_OVER", SWFBUTTONRECORD_OVERSTATE);
CONSTANT("SWFBUTTON_UP", SWFBUTTONRECORD_UPSTATE);
/* flags for SWFButton_addAction */
CONSTANT("SWFBUTTON_MOUSEUPOUTSIDE", SWFBUTTON_MOUSEUPOUTSIDE);
CONSTANT("SWFBUTTON_DRAGOVER", SWFBUTTON_DRAGOVER);
CONSTANT("SWFBUTTON_DRAGOUT", SWFBUTTON_DRAGOUT);
CONSTANT("SWFBUTTON_MOUSEUP", SWFBUTTON_MOUSEUP);
CONSTANT("SWFBUTTON_MOUSEDOWN", SWFBUTTON_MOUSEDOWN);
CONSTANT("SWFBUTTON_MOUSEOUT", SWFBUTTON_MOUSEOUT);
CONSTANT("SWFBUTTON_MOUSEOVER", SWFBUTTON_MOUSEOVER);
/* flags for SWFFill */
CONSTANT("SWFFILL_RADIAL_GRADIENT", SWFFILL_RADIAL_GRADIENT);
CONSTANT("SWFFILL_LINEAR_GRADIENT", SWFFILL_LINEAR_GRADIENT);
CONSTANT("SWFFILL_TILED_BITMAP", SWFFILL_TILED_BITMAP);
CONSTANT("SWFFILL_CLIPPED_BITMAP", SWFFILL_CLIPPED_BITMAP);
/* flags for SWFTextField_init */
CONSTANT("SWFTEXTFIELD_HASLENGTH", SWFTEXTFIELD_HASLENGTH);
CONSTANT("SWFTEXTFIELD_NOEDIT", SWFTEXTFIELD_NOEDIT);
CONSTANT("SWFTEXTFIELD_PASSWORD", SWFTEXTFIELD_PASSWORD);
CONSTANT("SWFTEXTFIELD_MULTILINE", SWFTEXTFIELD_MULTILINE);
CONSTANT("SWFTEXTFIELD_WORDWRAP", SWFTEXTFIELD_WORDWRAP);
CONSTANT("SWFTEXTFIELD_DRAWBOX", SWFTEXTFIELD_DRAWBOX);
CONSTANT("SWFTEXTFIELD_NOSELECT", SWFTEXTFIELD_NOSELECT);
CONSTANT("SWFTEXTFIELD_HTML", SWFTEXTFIELD_HTML);
/* flags for SWFTextField_align */
CONSTANT("SWFTEXTFIELD_ALIGN_LEFT", SWFTEXTFIELD_ALIGN_LEFT);
CONSTANT("SWFTEXTFIELD_ALIGN_RIGHT", SWFTEXTFIELD_ALIGN_RIGHT);
CONSTANT("SWFTEXTFIELD_ALIGN_CENTER", SWFTEXTFIELD_ALIGN_CENTER);
CONSTANT("SWFTEXTFIELD_ALIGN_JUSTIFY", SWFTEXTFIELD_ALIGN_JUSTIFY);
/* flags for SWFDisplayItem_addAction */
CONSTANT("SWFACTION_ONLOAD", SWFACTION_ONLOAD);
CONSTANT("SWFACTION_ENTERFRAME", SWFACTION_ENTERFRAME);
CONSTANT("SWFACTION_UNLOAD", SWFACTION_UNLOAD);
CONSTANT("SWFACTION_MOUSEMOVE", SWFACTION_MOUSEMOVE);
CONSTANT("SWFACTION_MOUSEDOWN", SWFACTION_MOUSEDOWN);
CONSTANT("SWFACTION_MOUSEUP", SWFACTION_MOUSEUP);
CONSTANT("SWFACTION_KEYDOWN", SWFACTION_KEYDOWN);
CONSTANT("SWFACTION_KEYUP", SWFACTION_KEYUP);
CONSTANT("SWFACTION_DATA", SWFACTION_DATA);
le_swfshapep = zend_register_list_destructors_ex(destroy_SWFShape_resource, NULL, "SWFShape", module_number);
le_swffillp = zend_register_list_destructors_ex(destroy_SWFFill_resource, NULL, "SWFFill", module_number);
le_swfgradientp = zend_register_list_destructors_ex(destroy_SWFGradient_resource, NULL, "SWFGradient", module_number);
le_swfbitmapp = zend_register_list_destructors_ex(destroy_SWFBitmap_resource, NULL, "SWFBitmap", module_number);
le_swftextp = zend_register_list_destructors_ex(destroy_SWFText_resource, NULL, "SWFText", module_number);
le_swftextfieldp = zend_register_list_destructors_ex(destroy_SWFTextField_resource, NULL, "SWFTextField", module_number);
le_swffontp = zend_register_list_destructors_ex(destroy_SWFFont_resource, NULL, "SWFFont", module_number);
le_swfdisplayitemp = zend_register_list_destructors_ex(NULL, NULL, "SWFDisplayItem", module_number);
le_swfmoviep = zend_register_list_destructors_ex(destroy_SWFMovie_resource, NULL, "SWFMovie", module_number);
2002-04-08 00:46:23 +00:00
le_swfbuttonp = zend_register_list_destructors_ex(destroy_SWFButton_resource, NULL, "SWFButton", module_number);
le_swfactionp = zend_register_list_destructors_ex(NULL, NULL, "SWFAction", module_number);
2002-04-08 00:46:23 +00:00
le_swfmorphp = zend_register_list_destructors_ex(destroy_SWFMorph_resource, NULL, "SWFMorph", module_number);
le_swfspritep = zend_register_list_destructors_ex(destroy_SWFSprite_resource, NULL, "SWFSprite", module_number);
le_swfinputp = zend_register_list_destructors_ex(destroy_SWFInput_resource, NULL, "SWFInput", module_number);
le_swfsoundp = zend_register_list_destructors_ex(destroy_SWFSound_resource, NULL, "SWFSound", module_number);
2003-11-12 09:12:51 +00:00
#ifdef HAVE_NEW_MING
le_swffontcharp = zend_register_list_destructors_ex(destroy_SWFFontCharacter_resource, NULL, "SWFFontCharacter", module_number);
le_swfsoundinstancep = zend_register_list_destructors_ex(NULL, NULL, "SWFSoundInstance", module_number);
2003-11-12 09:12:51 +00:00
#endif
2002-04-08 00:46:23 +00:00
INIT_CLASS_ENTRY(shape_class_entry, "swfshape", swfshape_functions);
INIT_CLASS_ENTRY(fill_class_entry, "swffill", swffill_functions);
INIT_CLASS_ENTRY(gradient_class_entry, "swfgradient", swfgradient_functions);
INIT_CLASS_ENTRY(bitmap_class_entry, "swfbitmap", swfbitmap_functions);
INIT_CLASS_ENTRY(text_class_entry, "swftext", swftext_functions);
INIT_CLASS_ENTRY(textfield_class_entry, "swftextfield", swftextfield_functions);
INIT_CLASS_ENTRY(font_class_entry, "swffont", swffont_functions);
INIT_CLASS_ENTRY(displayitem_class_entry, "swfdisplayitem", swfdisplayitem_functions);
INIT_CLASS_ENTRY(movie_class_entry, "swfmovie", swfmovie_functions);
INIT_CLASS_ENTRY(button_class_entry, "swfbutton", swfbutton_functions);
INIT_CLASS_ENTRY(action_class_entry, "swfaction", swfaction_functions);
INIT_CLASS_ENTRY(morph_class_entry, "swfmorph", swfmorph_functions);
INIT_CLASS_ENTRY(sprite_class_entry, "swfsprite", swfsprite_functions);
INIT_CLASS_ENTRY(sound_class_entry, "swfsound", swfsound_functions);
#ifdef HAVE_NEW_MING
INIT_CLASS_ENTRY(fontchar_class_entry, "swffontchar", swffontchar_functions);
INIT_CLASS_ENTRY(soundinstance_class_entry, "swfsoundinstance", swfsoundinstance_functions);
#endif
2002-04-08 00:46:23 +00:00
shape_class_entry_ptr = zend_register_internal_class(&shape_class_entry TSRMLS_CC);
fill_class_entry_ptr = zend_register_internal_class(&fill_class_entry TSRMLS_CC);
gradient_class_entry_ptr = zend_register_internal_class(&gradient_class_entry TSRMLS_CC);
bitmap_class_entry_ptr = zend_register_internal_class(&bitmap_class_entry TSRMLS_CC);
text_class_entry_ptr = zend_register_internal_class(&text_class_entry TSRMLS_CC);
textfield_class_entry_ptr = zend_register_internal_class(&textfield_class_entry TSRMLS_CC);
font_class_entry_ptr = zend_register_internal_class(&font_class_entry TSRMLS_CC);
displayitem_class_entry_ptr = zend_register_internal_class(&displayitem_class_entry TSRMLS_CC);
movie_class_entry_ptr = zend_register_internal_class(&movie_class_entry TSRMLS_CC);
button_class_entry_ptr = zend_register_internal_class(&button_class_entry TSRMLS_CC);
action_class_entry_ptr = zend_register_internal_class(&action_class_entry TSRMLS_CC);
morph_class_entry_ptr = zend_register_internal_class(&morph_class_entry TSRMLS_CC);
sprite_class_entry_ptr = zend_register_internal_class(&sprite_class_entry TSRMLS_CC);
2003-12-12 08:45:51 +00:00
sound_class_entry_ptr = zend_register_internal_class(&sound_class_entry TSRMLS_CC);
#ifdef HAVE_NEW_MING
fontchar_class_entry_ptr = zend_register_internal_class(&fontchar_class_entry TSRMLS_CC);
soundinstance_class_entry_ptr = zend_register_internal_class(&soundinstance_class_entry TSRMLS_CC);
#endif
2002-04-08 00:46:23 +00:00
return SUCCESS;
}
/* }}} */
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/