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_strings.h"
27 #include "swfdec_debug.h"
28 #include "swfdec_player_internal.h"
32 SWFDEC_AS_NATIVE (666, 1, get_scaleMode
)
34 get_scaleMode (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
35 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
37 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
39 switch (player
->scale_mode
) {
40 case SWFDEC_SCALE_SHOW_ALL
:
41 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_showAll
);
43 case SWFDEC_SCALE_NO_BORDER
:
44 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_noBorder
);
46 case SWFDEC_SCALE_EXACT_FIT
:
47 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_exactFit
);
49 case SWFDEC_SCALE_NONE
:
50 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_noScale
);
53 g_assert_not_reached ();
58 SWFDEC_AS_NATIVE (666, 2, set_scaleMode
)
60 set_scaleMode (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
61 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
63 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
69 s
= swfdec_as_value_to_string (cx
, &argv
[0]);
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
);
91 if (player
->align_flags
& SWFDEC_ALIGN_FLAG_LEFT
)
93 if (player
->align_flags
& SWFDEC_ALIGN_FLAG_TOP
)
95 if (player
->align_flags
& SWFDEC_ALIGN_FLAG_RIGHT
)
97 if (player
->align_flags
& SWFDEC_ALIGN_FLAG_BOTTOM
)
100 SWFDEC_AS_VALUE_SET_STRING (ret
, swfdec_as_context_get_string (cx
, s
));
103 SWFDEC_AS_NATIVE (666, 4, set_align
)
105 set_align (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
106 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
108 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
115 s
= swfdec_as_value_to_string (cx
, &argv
[0]);
116 if (strchr (s
, 'l') || strchr (s
, 'L'))
117 flags
|= SWFDEC_ALIGN_FLAG_LEFT
;
118 if (strchr (s
, 't') || strchr (s
, 'T'))
119 flags
|= SWFDEC_ALIGN_FLAG_TOP
;
120 if (strchr (s
, 'r') || strchr (s
, 'R'))
121 flags
|= SWFDEC_ALIGN_FLAG_RIGHT
;
122 if (strchr (s
, 'b') || strchr (s
, 'B'))
123 flags
|= SWFDEC_ALIGN_FLAG_BOTTOM
;
125 if (flags
!= player
->align_flags
) {
126 player
->align_flags
= flags
;
127 g_object_notify (G_OBJECT (player
), "alignment");
131 SWFDEC_AS_NATIVE (666, 5, get_width
)
133 get_width (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
134 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
136 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
138 SWFDEC_AS_VALUE_SET_INT (ret
, player
->internal_width
);
141 SWFDEC_AS_NATIVE (666, 7, get_height
)
143 get_height (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
144 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
146 SwfdecPlayer
*player
= SWFDEC_PLAYER (cx
);
148 SWFDEC_AS_VALUE_SET_INT (ret
, player
->internal_height
);
151 /* FIXME: do this smarter */
152 SWFDEC_AS_NATIVE (666, 6, set_width
)
154 set_width (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
155 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
159 SWFDEC_AS_NATIVE (666, 8, set_height
)
161 set_height (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
162 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)