2 * Copyright (C) 2007-2008 Benjamin Otte <otte@gnome.org>
3 * 2007 Pekka Lampila <pekka.lampila@iki.fi>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
27 #include <pango/pangocairo.h>
29 #include "swfdec_text_field.h"
30 #include "swfdec_text_field_movie.h"
31 #include "swfdec_as_strings.h"
32 #include "swfdec_debug.h"
33 #include "swfdec_as_native_function.h"
34 #include "swfdec_as_internal.h"
35 #include "swfdec_as_context.h"
36 #include "swfdec_as_object.h"
37 #include "swfdec_as_frame_internal.h"
38 #include "swfdec_internal.h"
39 #include "swfdec_player_internal.h"
42 swfdec_text_field_movie_int_to_color (SwfdecAsContext
*cx
, int value
)
45 value
= (0xffffff + 1) + value
% (0xffffff + 1);
47 value
= value
% (0xffffff + 1);
50 return SWFDEC_COLOR_COMBINE (value
>> 16 & 0xff, value
>> 8 & 0xff,
54 // does nothing but calls valueOf
56 swfdec_text_field_movie_set_readonly (SwfdecAsContext
*cx
,
57 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
60 SwfdecTextFieldMovie
*text
;
62 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
65 swfdec_as_value_to_number (cx
, &argv
[0]);
69 * Native properties: Text
72 swfdec_text_field_movie_do_get_text (SwfdecAsContext
*cx
,
73 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
76 SwfdecTextFieldMovie
*text
;
78 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
80 SWFDEC_AS_VALUE_SET_STRING (ret
, swfdec_text_field_movie_get_text (text
));
84 swfdec_text_field_movie_do_set_text (SwfdecAsContext
*cx
,
85 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
88 SwfdecTextFieldMovie
*text
;
91 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "s", &value
);
93 swfdec_text_field_movie_set_text (text
, value
, FALSE
);
94 swfdec_text_field_movie_update_layout (text
);
96 if (text
->variable
!= NULL
) {
98 swfdec_text_field_movie_set_listen_variable_text (text
,
99 swfdec_text_field_movie_get_html_text (text
));
101 swfdec_text_field_movie_set_listen_variable_text (text
,
102 swfdec_text_field_movie_get_text (text
));
108 swfdec_text_field_movie_get_html (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
109 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
111 SwfdecTextFieldMovie
*text
;
113 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
115 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->html
);
119 swfdec_text_field_movie_set_html (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
120 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
122 SwfdecTextFieldMovie
*text
;
125 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
127 swfdec_as_value_to_number (cx
, &argv
[0]);
131 // FIXME: resize? invalidate?
135 swfdec_text_field_movie_get_htmlText (SwfdecAsContext
*cx
,
136 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
139 SwfdecTextFieldMovie
*text
;
141 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
143 if (text
->style_sheet_input
) {
144 SWFDEC_AS_VALUE_SET_STRING (ret
, text
->style_sheet_input
);
145 } else if (text
->html
) {
146 SWFDEC_AS_VALUE_SET_STRING (ret
,
147 swfdec_text_field_movie_get_html_text (text
));
149 SWFDEC_AS_VALUE_SET_STRING (ret
,
150 swfdec_text_field_movie_get_text (text
));
155 swfdec_text_field_movie_set_htmlText (SwfdecAsContext
*cx
,
156 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
159 SwfdecTextFieldMovie
*text
;
162 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "s", &value
);
164 swfdec_text_field_movie_set_text (text
, value
, text
->html
);
166 if (text
->variable
!= NULL
) {
168 swfdec_text_field_movie_set_listen_variable_text (text
,
169 swfdec_text_field_movie_get_html_text (text
));
171 swfdec_text_field_movie_set_listen_variable_text (text
,
172 swfdec_text_field_movie_get_text (text
));
178 swfdec_text_field_movie_get_length (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
179 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
181 SwfdecTextFieldMovie
*text
;
183 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
185 swfdec_as_value_set_integer (cx
, ret
, g_utf8_strlen (swfdec_text_buffer_get_text (text
->text
), -1));
189 * Native properties: Input
192 swfdec_text_field_movie_get_condenseWhite (SwfdecAsContext
*cx
,
193 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
196 SwfdecTextFieldMovie
*text
;
198 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
200 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->condense_white
);
204 swfdec_text_field_movie_set_condenseWhite (SwfdecAsContext
*cx
,
205 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
208 SwfdecTextFieldMovie
*text
;
211 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
213 swfdec_as_value_to_number (cx
, &argv
[0]);
215 text
->condense_white
= value
;
219 swfdec_text_field_movie_get_maxChars (SwfdecAsContext
*cx
,
220 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
223 SwfdecTextFieldMovie
*text
;
225 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
227 if (text
->max_chars
!= 0) {
228 swfdec_as_value_set_integer (cx
, ret
, text
->max_chars
);
230 SWFDEC_AS_VALUE_SET_NULL (ret
);
235 swfdec_text_field_movie_set_maxChars (SwfdecAsContext
*cx
,
236 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
239 SwfdecTextFieldMovie
*text
;
241 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
246 swfdec_as_value_to_number (cx
, &argv
[0]);
247 text
->max_chars
= swfdec_as_value_to_integer (cx
, &argv
[0]);
251 swfdec_text_field_movie_get_multiline (SwfdecAsContext
*cx
,
252 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
255 SwfdecTextFieldMovie
*text
;
257 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
259 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->multiline
);
263 swfdec_text_field_movie_set_multiline (SwfdecAsContext
*cx
,
264 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
267 SwfdecTextFieldMovie
*text
;
270 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
272 swfdec_as_value_to_number (cx
, &argv
[0]);
274 text
->multiline
= value
;
278 swfdec_text_field_movie_get_restrict (SwfdecAsContext
*cx
,
279 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
282 SwfdecTextFieldMovie
*text
;
284 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
286 if (text
->restrict_
!= NULL
) {
287 SWFDEC_AS_VALUE_SET_STRING (ret
, text
->restrict_
);
289 SWFDEC_AS_VALUE_SET_NULL (ret
);
294 swfdec_text_field_movie_set_restrict (SwfdecAsContext
*cx
,
295 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
298 SwfdecTextFieldMovie
*text
;
302 swfdec_as_value_to_number (cx
, &argv
[0]);
304 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "s", &value
);
306 if (text
->restrict_
== NULL
&& value
== SWFDEC_AS_STR_EMPTY
)
309 if (SWFDEC_AS_VALUE_IS_UNDEFINED (*&argv
[0]) ||
310 SWFDEC_AS_VALUE_IS_NULL (*&argv
[0])) {
311 text
->restrict_
= NULL
;
313 text
->restrict_
= value
;
318 swfdec_text_field_movie_get_selectable (SwfdecAsContext
*cx
,
319 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
322 SwfdecTextFieldMovie
*text
;
324 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
326 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->selectable
);
330 swfdec_text_field_movie_set_selectable (SwfdecAsContext
*cx
,
331 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
334 SwfdecTextFieldMovie
*text
;
337 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
339 swfdec_as_value_to_number (cx
, &argv
[0]);
341 text
->selectable
= value
;
347 swfdec_text_field_movie_do_get_type (SwfdecAsContext
*cx
,
348 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
351 SwfdecTextFieldMovie
*text
;
353 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
355 if (text
->editable
) {
356 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_input
);
358 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_dynamic
);
363 swfdec_text_field_movie_do_set_type (SwfdecAsContext
*cx
,
364 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
367 SwfdecTextFieldMovie
*text
;
371 swfdec_as_value_to_number (cx
, &argv
[0]);
373 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "s", &value
);
375 if (!g_strcasecmp (value
, SWFDEC_AS_STR_input
)) {
376 text
->editable
= TRUE
;
377 } else if (!g_strcasecmp (value
, SWFDEC_AS_STR_dynamic
)) {
378 text
->editable
= FALSE
;
386 swfdec_text_field_movie_do_get_variable (SwfdecAsContext
*cx
,
387 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
390 SwfdecTextFieldMovie
*text
;
392 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
394 if (text
->variable
) {
395 SWFDEC_AS_VALUE_SET_STRING (ret
, text
->variable
);
397 SWFDEC_AS_VALUE_SET_NULL (ret
);
402 swfdec_text_field_movie_do_set_variable (SwfdecAsContext
*cx
,
403 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
406 SwfdecTextFieldMovie
*text
;
410 swfdec_as_value_to_number (cx
, &argv
[0]);
412 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "s", &value
);
414 if (SWFDEC_AS_VALUE_IS_UNDEFINED (*&argv
[0]) ||
415 SWFDEC_AS_VALUE_IS_NULL (*&argv
[0]) || value
== SWFDEC_AS_STR_EMPTY
) {
419 swfdec_text_field_movie_set_listen_variable (text
, value
);
423 * Native properties: Info
426 swfdec_text_field_movie_get_textHeight (SwfdecAsContext
*cx
,
427 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
430 SwfdecTextFieldMovie
*text
;
432 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
434 swfdec_movie_update (SWFDEC_MOVIE (text
));
435 swfdec_text_field_movie_update_layout (text
);
436 swfdec_as_value_set_integer (cx
, ret
, floor (text
->layout_height
*
437 text
->from_layout
.yy
/ SWFDEC_TWIPS_SCALE_FACTOR
));
441 swfdec_text_field_movie_get_textWidth (SwfdecAsContext
*cx
,
442 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
445 SwfdecTextFieldMovie
*text
;
447 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
449 swfdec_movie_update (SWFDEC_MOVIE (text
));
450 swfdec_text_field_movie_update_layout (text
);
451 swfdec_as_value_set_integer (cx
, ret
, floor (text
->layout_width
*
452 text
->from_layout
.xx
/ SWFDEC_TWIPS_SCALE_FACTOR
));
456 * Native properties: Background & border
459 swfdec_text_field_movie_get_background (SwfdecAsContext
*cx
,
460 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
463 SwfdecTextFieldMovie
*text
;
465 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
467 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->background
);
471 swfdec_text_field_movie_set_background (SwfdecAsContext
*cx
,
472 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
475 SwfdecTextFieldMovie
*text
;
478 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
480 swfdec_as_value_to_number (cx
, &argv
[0]);
482 if (text
->background
!= value
) {
483 text
->background
= value
;
484 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
489 swfdec_text_field_movie_get_backgroundColor (SwfdecAsContext
*cx
,
490 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
493 SwfdecTextFieldMovie
*text
;
495 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
497 swfdec_as_value_set_number (cx
, ret
,
498 SWFDEC_COLOR_RED (text
->background_color
) << 16 |
499 SWFDEC_COLOR_GREEN (text
->background_color
) << 8 |
500 SWFDEC_COLOR_BLUE (text
->background_color
));
504 swfdec_text_field_movie_set_backgroundColor (SwfdecAsContext
*cx
,
505 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
508 SwfdecTextFieldMovie
*text
;
512 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "i", &value
);
514 color
= swfdec_text_field_movie_int_to_color (cx
, value
);
515 if (text
->background_color
!= color
) {
516 text
->background_color
= color
;
517 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
522 swfdec_text_field_movie_get_border (SwfdecAsContext
*cx
,
523 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
526 SwfdecTextFieldMovie
*text
;
528 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
530 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->border
);
534 swfdec_text_field_movie_set_border (SwfdecAsContext
*cx
,
535 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
538 SwfdecTextFieldMovie
*text
;
541 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
543 swfdec_as_value_to_number (cx
, &argv
[0]);
545 if (text
->border
!= value
) {
546 text
->border
= value
;
547 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
552 swfdec_text_field_movie_get_borderColor (SwfdecAsContext
*cx
,
553 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
556 SwfdecTextFieldMovie
*text
;
558 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
561 swfdec_as_value_set_number (cx
, ret
,
562 SWFDEC_COLOR_RED (text
->border_color
) << 16 |
563 SWFDEC_COLOR_GREEN (text
->border_color
) << 8 |
564 SWFDEC_COLOR_BLUE (text
->border_color
));
568 swfdec_text_field_movie_set_borderColor (SwfdecAsContext
*cx
,
569 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
572 SwfdecTextFieldMovie
*text
;
576 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "i", &value
);
578 color
= swfdec_text_field_movie_int_to_color (cx
, value
);
579 if (text
->border_color
!= color
) {
580 text
->border_color
= color
;
581 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
586 * Native properties: Scrolling
589 swfdec_text_field_movie_get_bottomScroll (SwfdecAsContext
*cx
,
590 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
593 SwfdecTextFieldMovie
*text
;
595 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
597 swfdec_as_value_set_number (cx
, ret
, text
->scroll
+ text
->lines_visible
);
601 swfdec_text_field_movie_do_get_hscroll (SwfdecAsContext
*cx
,
602 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
605 SwfdecTextFieldMovie
*text
;
607 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
609 swfdec_as_value_set_number (cx
, ret
, text
->hscroll
);
613 swfdec_text_field_movie_do_set_hscroll (SwfdecAsContext
*cx
,
614 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
617 SwfdecTextFieldMovie
*text
;
620 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "i", &value
);
622 value
= CLAMP (value
, 0, (int) swfdec_text_field_movie_get_hscroll_max (text
));
623 if ((guint
) value
!= text
->hscroll
) {
624 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
625 text
->hscroll
= value
;
626 swfdec_text_field_movie_emit_onScroller (text
);
631 swfdec_text_field_movie_get_maxhscroll (SwfdecAsContext
*cx
,
632 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
635 SwfdecTextFieldMovie
*text
;
637 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
639 swfdec_as_value_set_integer (cx
, ret
, swfdec_text_field_movie_get_hscroll_max (text
));
643 swfdec_text_field_movie_get_maxscroll (SwfdecAsContext
*cx
,
644 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
647 SwfdecTextFieldMovie
*text
;
649 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
651 swfdec_as_value_set_number (cx
, ret
, text
->scroll_max
+ 1);
655 swfdec_text_field_movie_get_mouseWheelEnabled (SwfdecAsContext
*cx
,
656 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
659 SwfdecTextFieldMovie
*text
;
661 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
663 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->mouse_wheel_enabled
);
667 swfdec_text_field_movie_set_mouseWheelEnabled (SwfdecAsContext
*cx
,
668 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
671 SwfdecTextFieldMovie
*text
;
674 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
676 swfdec_as_value_to_number (cx
, &argv
[0]);
678 text
->mouse_wheel_enabled
= value
;
682 swfdec_text_field_movie_do_get_scroll (SwfdecAsContext
*cx
,
683 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
686 SwfdecTextFieldMovie
*text
;
688 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
690 swfdec_as_value_set_number (cx
, ret
, text
->scroll
+ 1);
694 swfdec_text_field_movie_do_set_scroll (SwfdecAsContext
*cx
,
695 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
698 SwfdecTextFieldMovie
*text
;
701 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "i", &value
);
703 if ((guint
) value
!= text
->scroll
+ 1) {
704 swfdec_text_field_movie_update_layout (text
);
705 value
= CLAMP (value
- 1, 0, (int) text
->scroll_max
);
706 text
->scroll
= value
;
707 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
708 swfdec_text_field_movie_emit_onScroller (text
);
713 * Native properties: Display
716 swfdec_text_field_movie_get_autoSize (SwfdecAsContext
*cx
,
717 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
720 SwfdecTextFieldMovie
*text
;
722 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
724 switch (text
->auto_size
) {
725 case SWFDEC_AUTO_SIZE_NONE
:
726 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_none
);
728 case SWFDEC_AUTO_SIZE_LEFT
:
729 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_left
);
731 case SWFDEC_AUTO_SIZE_RIGHT
:
732 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_right
);
734 case SWFDEC_AUTO_SIZE_CENTER
:
735 SWFDEC_AS_VALUE_SET_STRING (ret
, SWFDEC_AS_STR_center
);
738 g_assert_not_reached ();
743 swfdec_text_field_movie_set_autoSize (SwfdecAsContext
*cx
,
744 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
747 SwfdecTextFieldMovie
*text
;
750 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
755 if (SWFDEC_AS_VALUE_IS_BOOLEAN (*&argv
[0])) {
756 if (SWFDEC_AS_VALUE_GET_BOOLEAN (*&argv
[0])) {
757 text
->auto_size
= SWFDEC_AUTO_SIZE_LEFT
;
759 text
->auto_size
= SWFDEC_AUTO_SIZE_NONE
;
762 swfdec_as_value_to_number (cx
, &argv
[0]);
763 s
= swfdec_as_value_to_string (cx
, argv
[0]);
765 if (!g_ascii_strcasecmp (s
, "left")) {
766 text
->auto_size
= SWFDEC_AUTO_SIZE_LEFT
;
767 } else if (!g_ascii_strcasecmp (s
, "right")) {
768 text
->auto_size
= SWFDEC_AUTO_SIZE_RIGHT
;
769 } else if (!g_ascii_strcasecmp (s
, "center")) {
770 text
->auto_size
= SWFDEC_AUTO_SIZE_CENTER
;
772 text
->auto_size
= SWFDEC_AUTO_SIZE_NONE
;
778 swfdec_text_field_movie_get_password (SwfdecAsContext
*cx
,
779 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
782 SwfdecTextFieldMovie
*text
;
784 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
786 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, swfdec_text_layout_get_password (text
->layout
));
790 swfdec_text_field_movie_set_password (SwfdecAsContext
*cx
,
791 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
794 SwfdecTextFieldMovie
*text
;
797 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
799 swfdec_as_value_to_number (cx
, &argv
[0]);
801 swfdec_text_layout_set_password (text
->layout
, value
);
802 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
806 swfdec_text_field_movie_get_wordWrap (SwfdecAsContext
*cx
,
807 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
810 SwfdecTextFieldMovie
*text
;
812 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
814 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
,
815 swfdec_text_layout_get_word_wrap (text
->layout
));
819 swfdec_text_field_movie_set_wordWrap (SwfdecAsContext
*cx
,
820 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
823 SwfdecTextFieldMovie
*text
;
826 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
828 swfdec_as_value_to_number (cx
, &argv
[0]);
830 swfdec_text_layout_set_word_wrap (text
->layout
, value
);
834 * Native properties: Format
837 swfdec_text_field_movie_get_embedFonts (SwfdecAsContext
*cx
,
838 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
841 SwfdecTextFieldMovie
*text
;
843 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
845 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, text
->embed_fonts
);
849 swfdec_text_field_movie_set_embedFonts (SwfdecAsContext
*cx
,
850 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
853 SwfdecTextFieldMovie
*text
;
856 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "b", &value
);
858 swfdec_as_value_to_number (cx
, &argv
[0]);
860 if (!text
->embed_fonts
&& value
)
861 SWFDEC_FIXME ("Using embed fonts in TextField not supported");
863 text
->embed_fonts
= value
;
869 swfdec_text_field_movie_get_styleSheet (SwfdecAsContext
*cx
,
870 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
873 SwfdecTextFieldMovie
*text
;
875 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
877 if (text
->style_sheet
!= NULL
) {
878 SWFDEC_AS_VALUE_SET_OBJECT (ret
, text
->style_sheet
);
880 SWFDEC_AS_VALUE_SET_UNDEFINED (ret
);
885 swfdec_text_field_movie_style_sheet_update (SwfdecTextFieldMovie
*text
)
887 if (text
->style_sheet_input
)
888 swfdec_text_field_movie_set_text (text
, text
->style_sheet_input
, TRUE
);
892 swfdec_text_field_movie_set_styleSheet (SwfdecAsContext
*cx
,
893 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
896 SwfdecTextFieldMovie
*text
;
897 SwfdecAsObject
*value
;
899 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
904 swfdec_as_value_to_number (cx
, &argv
[0]);
906 if (SWFDEC_AS_VALUE_IS_OBJECT (*&argv
[0])) {
907 value
= SWFDEC_AS_VALUE_GET_OBJECT (*&argv
[0]);
912 if (text
->style_sheet
== value
)
915 if (text
->style_sheet
!= NULL
&& SWFDEC_IS_STYLE_SHEET (text
->style_sheet
->relay
)) {
916 g_signal_handlers_disconnect_by_func (text
->style_sheet
->relay
,
917 swfdec_text_field_movie_style_sheet_update
, text
);
918 g_object_remove_weak_pointer (G_OBJECT (text
->style_sheet
->relay
),
919 (gpointer
) &text
->style_sheet
);
922 text
->style_sheet
= value
;
924 if (value
&& SWFDEC_IS_STYLE_SHEET (value
->relay
)) {
925 g_signal_connect_swapped (value
->relay
, "update",
926 G_CALLBACK (swfdec_text_field_movie_style_sheet_update
), text
);
927 g_object_add_weak_pointer (G_OBJECT (text
->style_sheet
->relay
),
928 (gpointer
) &text
->style_sheet
);
930 swfdec_text_field_movie_style_sheet_update (text
);
935 swfdec_text_field_movie_get_textColor (SwfdecAsContext
*cx
,
936 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
939 SwfdecTextFieldMovie
*text
;
941 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
943 swfdec_as_value_set_number (cx
, ret
,
944 swfdec_text_buffer_get_default_attributes (text
->text
)->color
);
947 // This doesn't work the same way as TextFormat's color setting
949 swfdec_text_field_movie_set_textColor (SwfdecAsContext
*cx
,
950 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
953 SwfdecTextFieldMovie
*text
;
956 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "i", &value
);
958 /* FIXME: don't access private variables, you lazy hacker! */
959 text
->text
->default_attributes
.color
= swfdec_text_field_movie_int_to_color (cx
, value
);
962 SWFDEC_AS_NATIVE (104, 300, swfdec_text_field_movie_get_gridFitType
)
964 swfdec_text_field_movie_get_gridFitType (SwfdecAsContext
*cx
,
965 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
968 SWFDEC_STUB ("TextField.gridFitType (get)");
971 SWFDEC_AS_NATIVE (104, 301, swfdec_text_field_movie_set_gridFitType
)
973 swfdec_text_field_movie_set_gridFitType (SwfdecAsContext
*cx
,
974 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
977 SWFDEC_STUB ("TextField.gridFitType (set)");
980 SWFDEC_AS_NATIVE (104, 302, swfdec_text_field_movie_get_antiAliasType
)
982 swfdec_text_field_movie_get_antiAliasType (SwfdecAsContext
*cx
,
983 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
986 SWFDEC_STUB ("TextField.antiAliasType (get)");
989 SWFDEC_AS_NATIVE (104, 303, swfdec_text_field_movie_set_antiAliasType
)
991 swfdec_text_field_movie_set_antiAliasType (SwfdecAsContext
*cx
,
992 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
995 SWFDEC_STUB ("TextField.antiAliasType (set)");
998 SWFDEC_AS_NATIVE (104, 304, swfdec_text_field_movie_get_thickness
)
1000 swfdec_text_field_movie_get_thickness (SwfdecAsContext
*cx
,
1001 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1004 SWFDEC_STUB ("TextField.thickness (get)");
1007 SWFDEC_AS_NATIVE (104, 305, swfdec_text_field_movie_set_thickness
)
1009 swfdec_text_field_movie_set_thickness (SwfdecAsContext
*cx
,
1010 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1013 SWFDEC_STUB ("TextField.thickness (set)");
1016 SWFDEC_AS_NATIVE (104, 306, swfdec_text_field_movie_get_sharpness
)
1018 swfdec_text_field_movie_get_sharpness (SwfdecAsContext
*cx
,
1019 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1022 SWFDEC_STUB ("TextField.sharpness (get)");
1025 SWFDEC_AS_NATIVE (104, 307, swfdec_text_field_movie_set_sharpness
)
1027 swfdec_text_field_movie_set_sharpness (SwfdecAsContext
*cx
,
1028 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1031 SWFDEC_STUB ("TextField.sharpness (set)");
1034 SWFDEC_AS_NATIVE (104, 308, swfdec_text_field_movie_get_filters
)
1036 swfdec_text_field_movie_get_filters (SwfdecAsContext
*cx
,
1037 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1040 SWFDEC_STUB ("TextField.filters (get)");
1043 SWFDEC_AS_NATIVE (104, 309, swfdec_text_field_movie_set_filters
)
1045 swfdec_text_field_movie_set_filters (SwfdecAsContext
*cx
,
1046 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1049 SWFDEC_STUB ("TextField.filters (set)");
1055 SWFDEC_AS_NATIVE (104, 104, swfdec_text_field_movie_getNewTextFormat
)
1057 swfdec_text_field_movie_getNewTextFormat (SwfdecAsContext
*cx
,
1058 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1061 SwfdecTextFieldMovie
*text
;
1062 SwfdecTextFormat
*format
;
1064 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1066 format
= swfdec_text_format_new (cx
);
1068 swfdec_text_attributes_copy (&format
->attr
,
1069 swfdec_text_buffer_get_default_attributes (text
->text
),
1070 SWFDEC_TEXT_ATTRIBUTES_MASK
);
1071 format
->values_set
= SWFDEC_TEXT_ATTRIBUTES_MASK
;
1073 SWFDEC_AS_VALUE_SET_OBJECT (ret
, swfdec_as_relay_get_as_object (SWFDEC_AS_RELAY (format
)));
1076 SWFDEC_AS_NATIVE (104, 105, swfdec_text_field_movie_setNewTextFormat
)
1078 swfdec_text_field_movie_setNewTextFormat (SwfdecAsContext
*cx
,
1079 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1082 SwfdecTextFieldMovie
*text
;
1083 SwfdecAsObject
*format_object
;
1084 SwfdecTextFormat
*format
;
1086 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "o", &format_object
);
1088 if (!SWFDEC_IS_TEXT_FORMAT (format_object
->relay
))
1091 format
= SWFDEC_TEXT_FORMAT (format_object
->relay
);
1092 swfdec_text_buffer_set_default_attributes (text
->text
,
1093 &format
->attr
, format
->values_set
);
1096 SWFDEC_AS_NATIVE (104, 102, swfdec_text_field_movie_setTextFormat
)
1098 swfdec_text_field_movie_setTextFormat (SwfdecAsContext
*cx
,
1099 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1102 SwfdecTextFieldMovie
*text
;
1103 SwfdecTextFormat
*format
;
1107 gsize start
, end
, length
;
1109 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1114 string
= swfdec_text_buffer_get_text (text
->text
);
1115 length
= g_utf8_strlen (string
, -1);
1121 val
= swfdec_as_value_to_integer (cx
, &argv
[0]);
1122 start
= MAX (val
, 0);
1123 start
= MIN (start
, length
);
1125 if (val
< 0) { // fail
1128 end
= MIN (start
+ 1, length
);
1132 val
= swfdec_as_value_to_integer (cx
, &argv
[1]);
1134 end
= CLAMP (end
, start
, length
);
1141 if (!SWFDEC_AS_VALUE_IS_OBJECT (*&argv
[i
]))
1143 if (!SWFDEC_IS_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (*&argv
[i
])->relay
))
1146 format
= SWFDEC_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (*&argv
[i
])->relay
);
1147 start
= g_utf8_offset_to_pointer (string
, start
) - string
;
1148 end
= g_utf8_offset_to_pointer (string
, end
) - string
;
1150 swfdec_text_buffer_set_attributes (text
->text
, start
, end
- start
,
1151 &format
->attr
, format
->values_set
);
1153 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
1154 /* special case: update the max values, not the current values */
1155 /* swfdec_text_field_movie_update_layout (text); */
1156 /* FIXME: emit onScroller? */
1157 text
->layout_width
= swfdec_text_layout_get_width (text
->layout
);
1158 text
->layout_height
= swfdec_text_layout_get_height (text
->layout
);
1159 text
->scroll_max
= swfdec_text_layout_get_n_rows (text
->layout
)
1160 - swfdec_text_layout_get_visible_rows_end (text
->layout
,
1161 text
->layout_area
.height
);
1164 SWFDEC_AS_NATIVE (104, 101, swfdec_text_field_movie_getTextFormat
)
1166 swfdec_text_field_movie_getTextFormat (SwfdecAsContext
*cx
,
1167 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1170 SwfdecTextFieldMovie
*text
;
1171 SwfdecTextFormat
*format
;
1175 const SwfdecTextAttributes
*attr
;
1176 gsize start
, end
, length
;
1178 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1180 string
= swfdec_text_buffer_get_text (text
->text
);
1181 length
= g_utf8_strlen (string
, -1);
1183 format
= swfdec_text_format_new (cx
);
1184 SWFDEC_AS_VALUE_SET_OBJECT (ret
, swfdec_as_relay_get_as_object (SWFDEC_AS_RELAY (format
)));
1190 val
= swfdec_as_value_to_integer (cx
, &argv
[0]);
1191 start
= MAX (val
, 0);
1192 start
= MIN (start
, length
);
1194 if (val
< 0) { // fail
1197 end
= MIN (start
+ 1, length
);
1200 val
= swfdec_as_value_to_integer (cx
, &argv
[1]);
1202 end
= CLAMP (end
, start
, length
);
1209 start
= g_utf8_offset_to_pointer (string
, start
) - string
;
1210 end
= g_utf8_offset_to_pointer (string
, end
) - string
;
1211 mask
= swfdec_text_buffer_get_unique (text
->text
, start
, end
- start
);
1212 attr
= swfdec_text_buffer_get_attributes (text
->text
, start
);
1213 swfdec_text_attributes_copy (&format
->attr
, attr
, mask
);
1214 format
->values_set
= mask
;
1217 SWFDEC_AS_NATIVE (104, 100, swfdec_text_field_movie_replaceSel
)
1219 swfdec_text_field_movie_replaceSel (SwfdecAsContext
*cx
,
1220 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1223 SWFDEC_STUB ("TextField.replaceSel");
1226 SWFDEC_AS_NATIVE (104, 107, swfdec_text_field_movie_replaceText
)
1228 swfdec_text_field_movie_replaceText (SwfdecAsContext
*cx
,
1229 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1232 SwfdecTextFieldMovie
*text
;
1233 int start_index
, end_index
;
1234 const char *string
, *str
;
1237 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "iis", &start_index
,
1240 if (start_index
< 0)
1242 if (end_index
< start_index
)
1244 /* if there was a style sheet set when setting the text, modifications are
1246 if (text
->style_sheet_input
)
1249 string
= swfdec_text_buffer_get_text (text
->text
);
1250 start
= end
= g_utf8_strlen (string
, -1);
1251 start
= MIN ((gsize
) start_index
, start
);
1252 end
= MIN ((gsize
) end_index
, end
);
1253 start
= g_utf8_offset_to_pointer (string
, start
) - string
;
1254 end
= g_utf8_offset_to_pointer (string
, end
) - string
;
1256 /* anyone explain to me why Flash 7 has this special case plz */
1257 if (end
> start
&& (str
!= SWFDEC_AS_STR_EMPTY
|| cx
->version
!= 7))
1258 swfdec_text_buffer_delete_text (text
->text
, start
, end
- start
);
1260 swfdec_text_buffer_insert_text (text
->text
, start
, str
);
1261 /* yes, modifying text changes the default format */
1262 swfdec_text_buffer_set_default_attributes (text
->text
,
1263 swfdec_text_buffer_get_attributes (text
->text
, 0),
1264 SWFDEC_TEXT_ATTRIBUTES_MASK
);
1268 SWFDEC_AS_NATIVE (104, 201, swfdec_text_field_movie_getFontList
)
1270 swfdec_text_field_movie_getFontList (SwfdecAsContext
*cx
,
1271 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1274 SwfdecAsObject
*array
;
1276 PangoFontFamily
**families
;
1279 pango_font_map_list_families (pango_cairo_font_map_get_default (),
1280 &families
, &n_families
);
1282 array
= swfdec_as_array_new (cx
);
1283 for (i
= 0; i
< n_families
; i
++) {
1284 SWFDEC_AS_VALUE_SET_STRING (&val
, swfdec_as_context_get_string (cx
,
1285 pango_font_family_get_name (families
[i
])));
1286 swfdec_as_array_push (array
, &val
);
1288 SWFDEC_AS_VALUE_SET_STRING (&val
, SWFDEC_AS_STR_Sans
);
1289 swfdec_as_array_push (array
, &val
);
1290 SWFDEC_AS_VALUE_SET_STRING (&val
, SWFDEC_AS_STR_Serif
);
1291 swfdec_as_array_push (array
, &val
);
1292 SWFDEC_AS_VALUE_SET_STRING (&val
, SWFDEC_AS_STR_Monospace
);
1293 swfdec_as_array_push (array
, &val
);
1297 SWFDEC_AS_VALUE_SET_OBJECT (ret
, array
);
1300 SWFDEC_AS_NATIVE (104, 106, swfdec_text_field_movie_getDepth
)
1302 swfdec_text_field_movie_getDepth (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
1303 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
1305 SwfdecTextFieldMovie
*text
;
1307 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1309 swfdec_as_value_set_integer (cx
, rval
, SWFDEC_MOVIE (text
)->depth
);
1312 SWFDEC_AS_NATIVE (104, 103, swfdec_text_field_movie_removeTextField
)
1314 swfdec_text_field_movie_removeTextField (SwfdecAsContext
*cx
,
1315 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1316 SwfdecAsValue
*rval
)
1318 SwfdecTextFieldMovie
*text
;
1321 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1323 movie
= SWFDEC_MOVIE (text
);
1324 if (swfdec_depth_classify (movie
->depth
) == SWFDEC_DEPTH_CLASS_DYNAMIC
)
1325 swfdec_movie_remove (movie
);
1329 * Creating TextFields
1331 SWFDEC_AS_NATIVE (104, 200, swfdec_text_field_movie_createTextField
)
1333 swfdec_text_field_movie_createTextField (SwfdecAsContext
*cx
,
1334 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1335 SwfdecAsValue
*rval
)
1337 SwfdecMovie
*movie
, *parent
;
1338 SwfdecTextField
*edittext
;
1339 int depth
, x
, y
, width
, height
;
1341 SwfdecAsFunction
*fun
;
1342 SwfdecAsObject
*fun_object
, *o
;
1345 SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE
, &parent
, "siiiii", &name
, &depth
, &x
, &y
, &width
, &height
);
1346 width
= ABS (width
);
1347 height
= ABS (height
);
1349 edittext
= g_object_new (SWFDEC_TYPE_TEXT_FIELD
, NULL
);
1350 edittext
->html
= FALSE
;
1351 edittext
->editable
= FALSE
;
1352 edittext
->password
= FALSE
;
1353 edittext
->selectable
= TRUE
;
1354 edittext
->font
= NULL
; // FIXME
1355 edittext
->word_wrap
= FALSE
;
1356 edittext
->multiline
= FALSE
;
1357 edittext
->auto_size
= SWFDEC_AUTO_SIZE_NONE
;
1358 edittext
->border
= FALSE
;
1359 edittext
->size
= 240; // FIXME: Correct?
1361 edittext
->input
= NULL
;
1362 edittext
->variable
= NULL
;
1363 edittext
->color
= 0;
1364 edittext
->align
= SWFDEC_TEXT_ALIGN_LEFT
;
1365 edittext
->left_margin
= 0;
1366 edittext
->right_margin
= 0;
1367 edittext
->indent
= 0;
1368 edittext
->leading
= 0;
1370 SWFDEC_GRAPHIC (edittext
)->extents
.x0
= 0;
1371 SWFDEC_GRAPHIC (edittext
)->extents
.x1
= SWFDEC_DOUBLE_TO_TWIPS (width
);
1372 SWFDEC_GRAPHIC (edittext
)->extents
.y0
= 0;
1373 SWFDEC_GRAPHIC (edittext
)->extents
.y1
= SWFDEC_DOUBLE_TO_TWIPS (height
);
1375 movie
= swfdec_movie_find (parent
, depth
);
1377 swfdec_movie_remove (movie
);
1379 movie
= swfdec_movie_new (SWFDEC_PLAYER (cx
), depth
, parent
, parent
->resource
,
1380 SWFDEC_GRAPHIC (edittext
), name
);
1381 g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (movie
));
1382 g_object_unref (edittext
);
1384 swfdec_movie_begin_update_matrix (movie
);
1385 movie
->matrix
.x0
= SWFDEC_DOUBLE_TO_TWIPS (x
);
1386 movie
->matrix
.y0
= SWFDEC_DOUBLE_TO_TWIPS (y
);
1387 movie
->modified
= TRUE
;
1388 swfdec_movie_end_update_matrix (movie
);
1390 swfdec_movie_initialize (movie
);
1391 swfdec_movie_update (movie
);
1393 swfdec_as_object_get_variable (cx
->global
, SWFDEC_AS_STR_TextField
, &val
);
1394 if (!SWFDEC_AS_VALUE_IS_OBJECT (*&val
))
1396 fun_object
= SWFDEC_AS_VALUE_GET_OBJECT (*&val
);
1397 if (!SWFDEC_IS_AS_FUNCTION (fun_object
->relay
))
1399 fun
= SWFDEC_AS_FUNCTION (fun_object
->relay
);
1401 /* set initial variables */
1402 o
= swfdec_as_relay_get_as_object (SWFDEC_AS_RELAY (movie
));
1403 if (swfdec_as_object_get_variable (fun_object
,
1404 SWFDEC_AS_STR_prototype
, &val
)) {
1405 swfdec_as_object_set_variable_and_flags (o
,
1406 SWFDEC_AS_STR___proto__
, &val
,
1407 SWFDEC_AS_VARIABLE_HIDDEN
| SWFDEC_AS_VARIABLE_PERMANENT
);
1409 SWFDEC_AS_VALUE_SET_OBJECT (&val
, fun_object
);
1410 if (cx
->version
< 7) {
1411 swfdec_as_object_set_variable_and_flags (o
,
1412 SWFDEC_AS_STR_constructor
, &val
, SWFDEC_AS_VARIABLE_HIDDEN
);
1414 swfdec_as_object_set_variable_and_flags (o
,
1415 SWFDEC_AS_STR___constructor__
, &val
,
1416 SWFDEC_AS_VARIABLE_HIDDEN
| SWFDEC_AS_VARIABLE_VERSION_6_UP
);
1418 swfdec_as_function_call_full (fun
, o
, TRUE
, NULL
,
1419 0, NULL
, cx
->version
> 7 ? rval
: &val
);
1423 swfdec_text_field_movie_init_properties (SwfdecAsContext
*cx
)
1426 SwfdecAsObject
*object
, *proto
;
1428 // FIXME: We should only initialize if the prototype Object has not been
1429 // initialized by any object's constructor with native properties
1430 // (TextField, TextFormat, XML, XMLNode at least)
1432 g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx
));
1434 swfdec_as_object_get_variable (cx
->global
, SWFDEC_AS_STR_TextField
, &val
);
1435 if (!SWFDEC_AS_VALUE_IS_OBJECT (*&val
))
1437 object
= SWFDEC_AS_VALUE_GET_OBJECT (*&val
);
1438 swfdec_as_object_get_variable (object
, SWFDEC_AS_STR_prototype
, &val
);
1439 if (!SWFDEC_AS_VALUE_IS_OBJECT (*&val
))
1441 proto
= SWFDEC_AS_VALUE_GET_OBJECT (*&val
);
1444 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_text
,
1445 swfdec_text_field_movie_do_get_text
,
1446 swfdec_text_field_movie_do_set_text
);
1447 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_html
,
1448 swfdec_text_field_movie_get_html
, swfdec_text_field_movie_set_html
);
1449 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_htmlText
,
1450 swfdec_text_field_movie_get_htmlText
,
1451 swfdec_text_field_movie_set_htmlText
);
1452 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_length
,
1453 swfdec_text_field_movie_get_length
,
1454 swfdec_text_field_movie_set_readonly
);
1457 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_condenseWhite
,
1458 swfdec_text_field_movie_get_condenseWhite
,
1459 swfdec_text_field_movie_set_condenseWhite
);
1460 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_maxChars
,
1461 swfdec_text_field_movie_get_maxChars
,
1462 swfdec_text_field_movie_set_maxChars
);
1463 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_multiline
,
1464 swfdec_text_field_movie_get_multiline
,
1465 swfdec_text_field_movie_set_multiline
);
1466 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_restrict
,
1467 swfdec_text_field_movie_get_restrict
,
1468 swfdec_text_field_movie_set_restrict
);
1469 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_selectable
,
1470 swfdec_text_field_movie_get_selectable
,
1471 swfdec_text_field_movie_set_selectable
);
1472 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_type
,
1473 swfdec_text_field_movie_do_get_type
,
1474 swfdec_text_field_movie_do_set_type
);
1475 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_variable
,
1476 swfdec_text_field_movie_do_get_variable
,
1477 swfdec_text_field_movie_do_set_variable
);
1480 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_textHeight
,
1481 swfdec_text_field_movie_get_textHeight
,
1482 swfdec_text_field_movie_set_readonly
);
1483 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_textWidth
,
1484 swfdec_text_field_movie_get_textWidth
,
1485 swfdec_text_field_movie_set_readonly
);
1487 // border & background
1488 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_background
,
1489 swfdec_text_field_movie_get_background
,
1490 swfdec_text_field_movie_set_background
);
1491 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_backgroundColor
,
1492 swfdec_text_field_movie_get_backgroundColor
,
1493 swfdec_text_field_movie_set_backgroundColor
);
1494 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_border
,
1495 swfdec_text_field_movie_get_border
, swfdec_text_field_movie_set_border
);
1496 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_borderColor
,
1497 swfdec_text_field_movie_get_borderColor
,
1498 swfdec_text_field_movie_set_borderColor
);
1501 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_bottomScroll
,
1502 swfdec_text_field_movie_get_bottomScroll
,
1503 swfdec_text_field_movie_set_readonly
);
1504 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_hscroll
,
1505 swfdec_text_field_movie_do_get_hscroll
,
1506 swfdec_text_field_movie_do_set_hscroll
);
1507 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_maxhscroll
,
1508 swfdec_text_field_movie_get_maxhscroll
,
1509 swfdec_text_field_movie_set_readonly
);
1510 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_maxscroll
,
1511 swfdec_text_field_movie_get_maxscroll
,
1512 swfdec_text_field_movie_set_readonly
);
1513 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_mouseWheelEnabled
,
1514 swfdec_text_field_movie_get_mouseWheelEnabled
,
1515 swfdec_text_field_movie_set_mouseWheelEnabled
);
1516 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_scroll
,
1517 swfdec_text_field_movie_do_get_scroll
,
1518 swfdec_text_field_movie_do_set_scroll
);
1521 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_autoSize
,
1522 swfdec_text_field_movie_get_autoSize
,
1523 swfdec_text_field_movie_set_autoSize
);
1524 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_password
,
1525 swfdec_text_field_movie_get_password
,
1526 swfdec_text_field_movie_set_password
);
1527 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_wordWrap
,
1528 swfdec_text_field_movie_get_wordWrap
,
1529 swfdec_text_field_movie_set_wordWrap
);
1532 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_embedFonts
,
1533 swfdec_text_field_movie_get_embedFonts
,
1534 swfdec_text_field_movie_set_embedFonts
);
1535 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_styleSheet
,
1536 swfdec_text_field_movie_get_styleSheet
,
1537 swfdec_text_field_movie_set_styleSheet
);
1538 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_textColor
,
1539 swfdec_text_field_movie_get_textColor
,
1540 swfdec_text_field_movie_set_textColor
);
1542 // TODO: menu, tabEnabled, tabIndex
1544 // Version 8 properties have ASnative numbers:
1545 // gridFitType, antiAliasType, thickness, sharpness and filters
1548 SWFDEC_AS_NATIVE (104, 0, swfdec_text_field_movie_construct
)
1550 swfdec_text_field_movie_construct (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
1551 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
1553 if (!cx
->frame
->construct
) {
1554 object
= swfdec_as_object_new_empty (cx
);
1555 swfdec_as_object_set_constructor_by_name (object
, SWFDEC_AS_STR_TextField
, NULL
);
1558 swfdec_text_field_movie_init_properties (cx
);
1560 // FIXME: do object.addListener (object);
1562 SWFDEC_AS_VALUE_SET_COMPOSITE (ret
, object
);