SwfdecAsObjectClass is gone now
[swfdec.git] / swfdec / swfdec_stage_as.c
blob84feaf4a22c66fee8d4862d03ed25b0fd3f0e77f
1 /* Swfdec
2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include <string.h>
25 #include "swfdec_as_internal.h"
26 #include "swfdec_as_native_function.h"
27 #include "swfdec_as_strings.h"
28 #include "swfdec_debug.h"
29 #include "swfdec_player_internal.h"
31 /*** AS CODE ***/
33 SWFDEC_AS_NATIVE (666, 1, get_scaleMode)
34 void
35 get_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
36 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
38 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
40 switch (player->priv->scale_mode) {
41 case SWFDEC_SCALE_SHOW_ALL:
42 SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_showAll);
43 break;
44 case SWFDEC_SCALE_NO_BORDER:
45 SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noBorder);
46 break;
47 case SWFDEC_SCALE_EXACT_FIT:
48 SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_exactFit);
49 break;
50 case SWFDEC_SCALE_NONE:
51 SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_noScale);
52 break;
53 default:
54 g_assert_not_reached ();
55 break;
59 SWFDEC_AS_NATIVE (666, 2, set_scaleMode)
60 void
61 set_scaleMode (SwfdecAsContext *cx, SwfdecAsObject *object,
62 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
64 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
65 const char *s;
66 SwfdecScaleMode mode;
68 SWFDEC_AS_CHECK (0, NULL, "s", &s);
70 if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noBorder) == 0) {
71 mode = SWFDEC_SCALE_NO_BORDER;
72 } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_exactFit) == 0) {
73 mode = SWFDEC_SCALE_EXACT_FIT;
74 } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_noScale) == 0) {
75 mode = SWFDEC_SCALE_NONE;
76 } else {
77 mode = SWFDEC_SCALE_SHOW_ALL;
79 swfdec_player_set_scale_mode (player, mode);
82 SWFDEC_AS_NATIVE (666, 3, get_align)
83 void
84 get_align (SwfdecAsContext *cx, SwfdecAsObject *object,
85 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
87 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
88 SwfdecPlayerPrivate *priv = player->priv;
89 char s[5];
90 guint i = 0;
92 if (priv->align_flags & SWFDEC_ALIGN_FLAG_LEFT)
93 s[i++] = 'L';
94 if (priv->align_flags & SWFDEC_ALIGN_FLAG_TOP)
95 s[i++] = 'T';
96 if (priv->align_flags & SWFDEC_ALIGN_FLAG_RIGHT)
97 s[i++] = 'R';
98 if (priv->align_flags & SWFDEC_ALIGN_FLAG_BOTTOM)
99 s[i++] = 'B';
100 s[i] = 0;
101 SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_context_get_string (cx, s));
104 SWFDEC_AS_NATIVE (666, 4, set_align)
105 void
106 set_align (SwfdecAsContext *cx, SwfdecAsObject *object,
107 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
109 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
110 guint flags = 0;
111 const char *s;
113 SWFDEC_AS_CHECK (0, NULL, "s", &s);
115 if (strchr (s, 'l') || strchr (s, 'L'))
116 flags |= SWFDEC_ALIGN_FLAG_LEFT;
117 if (strchr (s, 't') || strchr (s, 'T'))
118 flags |= SWFDEC_ALIGN_FLAG_TOP;
119 if (strchr (s, 'r') || strchr (s, 'R'))
120 flags |= SWFDEC_ALIGN_FLAG_RIGHT;
121 if (strchr (s, 'b') || strchr (s, 'B'))
122 flags |= SWFDEC_ALIGN_FLAG_BOTTOM;
124 if (flags != player->priv->align_flags) {
125 player->priv->align_flags = flags;
126 g_object_notify (G_OBJECT (player), "alignment");
127 swfdec_player_update_scale (player);
131 SWFDEC_AS_NATIVE (666, 5, get_width)
132 void
133 get_width (SwfdecAsContext *cx, SwfdecAsObject *object,
134 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
136 SwfdecPlayerPrivate *priv = SWFDEC_PLAYER (cx)->priv;
138 if (priv->scale_mode == SWFDEC_SCALE_NONE)
139 *ret = swfdec_as_value_from_integer (cx, priv->internal_width);
140 else
141 *ret = swfdec_as_value_from_integer (cx, priv->width);
144 SWFDEC_AS_NATIVE (666, 7, get_height)
145 void
146 get_height (SwfdecAsContext *cx, SwfdecAsObject *object,
147 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
149 SwfdecPlayerPrivate *priv = SWFDEC_PLAYER (cx)->priv;
151 if (priv->scale_mode == SWFDEC_SCALE_NONE)
152 *ret = swfdec_as_value_from_integer (cx, priv->internal_height);
153 else
154 *ret = swfdec_as_value_from_integer (cx, priv->height);
157 /* FIXME: do this smarter */
158 SWFDEC_AS_NATIVE (666, 6, set_width)
159 void
160 set_width (SwfdecAsContext *cx, SwfdecAsObject *object,
161 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
165 SWFDEC_AS_NATIVE (666, 8, set_height)
166 void
167 set_height (SwfdecAsContext *cx, SwfdecAsObject *object,
168 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
172 SWFDEC_AS_NATIVE (666, 9, swfdec_stage_get_showMenu)
173 void
174 swfdec_stage_get_showMenu (SwfdecAsContext *cx, SwfdecAsObject *object,
175 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
177 SWFDEC_STUB ("Stage.showMenu (get)");
180 SWFDEC_AS_NATIVE (666, 10, swfdec_stage_set_showMenu)
181 void
182 swfdec_stage_set_showMenu (SwfdecAsContext *cx, SwfdecAsObject *object,
183 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
185 SWFDEC_STUB ("Stage.showMenu (set)");
188 SWFDEC_AS_NATIVE (666, 11, swfdec_stage_get_displayState)
189 void
190 swfdec_stage_get_displayState (SwfdecAsContext *cx, SwfdecAsObject *object,
191 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
193 SwfdecPlayerPrivate *priv = SWFDEC_PLAYER (cx)->priv;
195 if (priv->fullscreen)
196 SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_fullScreen);
197 else
198 SWFDEC_AS_VALUE_SET_STRING (ret, SWFDEC_AS_STR_normal);
201 SWFDEC_AS_NATIVE (666, 12, swfdec_stage_set_displayState)
202 void
203 swfdec_stage_set_displayState (SwfdecAsContext *cx, SwfdecAsObject *object,
204 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
206 SwfdecPlayer *player = SWFDEC_PLAYER (cx);
207 const char *s;
209 SWFDEC_AS_CHECK (0, NULL, "s", &s);
211 if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_normal) == 0) {
212 swfdec_player_set_fullscreen (player, FALSE);
213 } else if (g_ascii_strcasecmp (s, SWFDEC_AS_STR_fullScreen) == 0) {
214 swfdec_player_set_fullscreen (player, TRUE);
218 SWFDEC_AS_NATIVE (666, 100, swfdec_stage_get_fullScreenSourceRect)
219 void
220 swfdec_stage_get_fullScreenSourceRect (SwfdecAsContext *cx, SwfdecAsObject *object,
221 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
223 SWFDEC_STUB ("Stage.fullScreenSourceRect (get)");
226 SWFDEC_AS_NATIVE (666, 101, swfdec_stage_set_fullScreenSourceRect)
227 void
228 swfdec_stage_set_fullScreenSourceRect (SwfdecAsContext *cx, SwfdecAsObject *object,
229 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
231 SWFDEC_STUB ("Stage.fullScreenSourceRect (set)");
234 SWFDEC_AS_NATIVE (666, 102, swfdec_stage_get_fullScreenHeight)
235 void
236 swfdec_stage_get_fullScreenHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
237 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
239 SWFDEC_STUB ("Stage.fullScreenHeight (get)");
242 SWFDEC_AS_NATIVE (666, 103, swfdec_stage_set_fullScreenHeight)
243 void
244 swfdec_stage_set_fullScreenHeight (SwfdecAsContext *cx, SwfdecAsObject *object,
245 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
247 SWFDEC_STUB ("Stage.fullScreenHeight (set)");
250 SWFDEC_AS_NATIVE (666, 104, swfdec_stage_get_fullScreenWidth)
251 void
252 swfdec_stage_get_fullScreenWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
253 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
255 SWFDEC_STUB ("Stage.fullScreenWidth (get)");
258 SWFDEC_AS_NATIVE (666, 105, swfdec_stage_set_fullScreenWidth)
259 void
260 swfdec_stage_set_fullScreenWidth (SwfdecAsContext *cx, SwfdecAsObject *object,
261 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
263 SWFDEC_STUB ("Stage.fullScreenWidth (set)");