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.
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
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"
33 SWFDEC_AS_NATIVE (666, 1, get_scaleMode
)
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
);
44 case SWFDEC_SCALE_NO_BORDER
:
45 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_noBorder
);
47 case SWFDEC_SCALE_EXACT_FIT
:
48 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_exactFit
);
50 case SWFDEC_SCALE_NONE
:
51 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_noScale
);
54 g_assert_not_reached ();
59 SWFDEC_AS_NATIVE (666, 2, set_scaleMode
)
61 set_scaleMode (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
62 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
64 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
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
;
77 mode
= SWFDEC_SCALE_SHOW_ALL
;
79 swfdec_player_set_scale_mode (player
, mode
);
82 SWFDEC_AS_NATIVE (666, 3, get_align
)
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
;
92 if (priv
->align_flags
& SWFDEC_ALIGN_FLAG_LEFT
)
94 if (priv
->align_flags
& SWFDEC_ALIGN_FLAG_TOP
)
96 if (priv
->align_flags
& SWFDEC_ALIGN_FLAG_RIGHT
)
98 if (priv
->align_flags
& SWFDEC_ALIGN_FLAG_BOTTOM
)
101 SWFDEC_AS_VALUE_SET_STRING (ret
, swfdec_as_context_get_string (cx
, s
));
104 SWFDEC_AS_NATIVE (666, 4, set_align
)
106 set_align (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
107 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
109 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
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
)
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
);
141 *ret
= swfdec_as_value_from_integer (cx
, priv
->width
);
144 SWFDEC_AS_NATIVE (666, 7, get_height
)
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
);
154 *ret
= swfdec_as_value_from_integer (cx
, priv
->height
);
157 /* FIXME: do this smarter */
158 SWFDEC_AS_NATIVE (666, 6, set_width
)
160 set_width (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
161 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
165 SWFDEC_AS_NATIVE (666, 8, set_height
)
167 set_height (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
168 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
172 SWFDEC_AS_NATIVE (666, 9, swfdec_stage_get_showMenu
)
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
)
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
)
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
);
198 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_normal
);
201 SWFDEC_AS_NATIVE (666, 12, swfdec_stage_set_displayState
)
203 swfdec_stage_set_displayState (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
204 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
206 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
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
)
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
)
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
)
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
)
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
)
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
)
260 swfdec_stage_set_fullScreenWidth (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
261 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
263 SWFDEC_STUB ("Stage.fullScreenWidth (set)");