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
, SWFDEC_AS_OBJECT (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]);
908 if (SWFDEC_IS_MOVIE (value
))
914 if (text
->style_sheet
== value
)
917 if (text
->style_sheet
!= NULL
&& SWFDEC_IS_STYLESHEET (text
->style_sheet
)) {
918 g_signal_handlers_disconnect_by_func (text
->style_sheet
,
919 swfdec_text_field_movie_style_sheet_update
, text
);
920 g_object_remove_weak_pointer (G_OBJECT (text
->style_sheet
),
921 (gpointer
) &text
->style_sheet
);
924 text
->style_sheet
= value
;
926 if (SWFDEC_IS_STYLESHEET (value
)) {
927 g_signal_connect_swapped (value
, "update",
928 G_CALLBACK (swfdec_text_field_movie_style_sheet_update
), text
);
929 g_object_add_weak_pointer (G_OBJECT (text
->style_sheet
),
930 (gpointer
) &text
->style_sheet
);
932 swfdec_text_field_movie_style_sheet_update (text
);
937 swfdec_text_field_movie_get_textColor (SwfdecAsContext
*cx
,
938 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
941 SwfdecTextFieldMovie
*text
;
943 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
945 swfdec_as_value_set_number (cx
, ret
,
946 swfdec_text_buffer_get_default_attributes (text
->text
)->color
);
949 // This doesn't work the same way as TextFormat's color setting
951 swfdec_text_field_movie_set_textColor (SwfdecAsContext
*cx
,
952 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
955 SwfdecTextFieldMovie
*text
;
958 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "i", &value
);
960 /* FIXME: don't access private variables, you lazy hacker! */
961 text
->text
->default_attributes
.color
= swfdec_text_field_movie_int_to_color (cx
, value
);
964 SWFDEC_AS_NATIVE (104, 300, swfdec_text_field_movie_get_gridFitType
)
966 swfdec_text_field_movie_get_gridFitType (SwfdecAsContext
*cx
,
967 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
970 SWFDEC_STUB ("TextField.gridFitType (get)");
973 SWFDEC_AS_NATIVE (104, 301, swfdec_text_field_movie_set_gridFitType
)
975 swfdec_text_field_movie_set_gridFitType (SwfdecAsContext
*cx
,
976 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
979 SWFDEC_STUB ("TextField.gridFitType (set)");
982 SWFDEC_AS_NATIVE (104, 302, swfdec_text_field_movie_get_antiAliasType
)
984 swfdec_text_field_movie_get_antiAliasType (SwfdecAsContext
*cx
,
985 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
988 SWFDEC_STUB ("TextField.antiAliasType (get)");
991 SWFDEC_AS_NATIVE (104, 303, swfdec_text_field_movie_set_antiAliasType
)
993 swfdec_text_field_movie_set_antiAliasType (SwfdecAsContext
*cx
,
994 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
997 SWFDEC_STUB ("TextField.antiAliasType (set)");
1000 SWFDEC_AS_NATIVE (104, 304, swfdec_text_field_movie_get_thickness
)
1002 swfdec_text_field_movie_get_thickness (SwfdecAsContext
*cx
,
1003 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1006 SWFDEC_STUB ("TextField.thickness (get)");
1009 SWFDEC_AS_NATIVE (104, 305, swfdec_text_field_movie_set_thickness
)
1011 swfdec_text_field_movie_set_thickness (SwfdecAsContext
*cx
,
1012 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1015 SWFDEC_STUB ("TextField.thickness (set)");
1018 SWFDEC_AS_NATIVE (104, 306, swfdec_text_field_movie_get_sharpness
)
1020 swfdec_text_field_movie_get_sharpness (SwfdecAsContext
*cx
,
1021 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1024 SWFDEC_STUB ("TextField.sharpness (get)");
1027 SWFDEC_AS_NATIVE (104, 307, swfdec_text_field_movie_set_sharpness
)
1029 swfdec_text_field_movie_set_sharpness (SwfdecAsContext
*cx
,
1030 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1033 SWFDEC_STUB ("TextField.sharpness (set)");
1036 SWFDEC_AS_NATIVE (104, 308, swfdec_text_field_movie_get_filters
)
1038 swfdec_text_field_movie_get_filters (SwfdecAsContext
*cx
,
1039 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1042 SWFDEC_STUB ("TextField.filters (get)");
1045 SWFDEC_AS_NATIVE (104, 309, swfdec_text_field_movie_set_filters
)
1047 swfdec_text_field_movie_set_filters (SwfdecAsContext
*cx
,
1048 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1051 SWFDEC_STUB ("TextField.filters (set)");
1057 SWFDEC_AS_NATIVE (104, 104, swfdec_text_field_movie_getNewTextFormat
)
1059 swfdec_text_field_movie_getNewTextFormat (SwfdecAsContext
*cx
,
1060 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1063 SwfdecTextFieldMovie
*text
;
1064 SwfdecTextFormat
*format
;
1066 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1068 format
= SWFDEC_TEXT_FORMAT (swfdec_text_format_new (cx
));
1072 swfdec_text_attributes_copy (&format
->attr
,
1073 swfdec_text_buffer_get_default_attributes (text
->text
),
1074 SWFDEC_TEXT_ATTRIBUTES_MASK
);
1075 format
->values_set
= SWFDEC_TEXT_ATTRIBUTES_MASK
;
1077 SWFDEC_AS_VALUE_SET_OBJECT (ret
, SWFDEC_AS_OBJECT (format
));
1080 SWFDEC_AS_NATIVE (104, 105, swfdec_text_field_movie_setNewTextFormat
)
1082 swfdec_text_field_movie_setNewTextFormat (SwfdecAsContext
*cx
,
1083 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1086 SwfdecTextFieldMovie
*text
;
1087 SwfdecTextFormat
*format
;
1089 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "o", &format
);
1091 if (!SWFDEC_IS_TEXT_FORMAT (format
))
1094 swfdec_text_buffer_set_default_attributes (text
->text
,
1095 &format
->attr
, format
->values_set
);
1098 SWFDEC_AS_NATIVE (104, 102, swfdec_text_field_movie_setTextFormat
)
1100 swfdec_text_field_movie_setTextFormat (SwfdecAsContext
*cx
,
1101 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1104 SwfdecTextFieldMovie
*text
;
1105 SwfdecTextFormat
*format
;
1109 gsize start
, end
, length
;
1111 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1116 string
= swfdec_text_buffer_get_text (text
->text
);
1117 length
= g_utf8_strlen (string
, -1);
1123 val
= swfdec_as_value_to_integer (cx
, &argv
[0]);
1124 start
= MAX (val
, 0);
1125 start
= MIN (start
, length
);
1127 if (val
< 0) { // fail
1130 end
= MIN (start
+ 1, length
);
1134 val
= swfdec_as_value_to_integer (cx
, &argv
[1]);
1136 end
= CLAMP (end
, start
, length
);
1143 if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv
[i
]))
1145 if (!SWFDEC_IS_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&argv
[i
])))
1148 format
= SWFDEC_TEXT_FORMAT (SWFDEC_AS_VALUE_GET_OBJECT (&argv
[i
]));
1149 start
= g_utf8_offset_to_pointer (string
, start
) - string
;
1150 end
= g_utf8_offset_to_pointer (string
, end
) - string
;
1152 swfdec_text_buffer_set_attributes (text
->text
, start
, end
- start
,
1153 &format
->attr
, format
->values_set
);
1155 swfdec_movie_invalidate_last (SWFDEC_MOVIE (text
));
1156 /* special case: update the max values, not the current values */
1157 /* swfdec_text_field_movie_update_layout (text); */
1158 /* FIXME: emit onScroller? */
1159 text
->layout_width
= swfdec_text_layout_get_width (text
->layout
);
1160 text
->layout_height
= swfdec_text_layout_get_height (text
->layout
);
1161 text
->scroll_max
= swfdec_text_layout_get_n_rows (text
->layout
)
1162 - swfdec_text_layout_get_visible_rows_end (text
->layout
,
1163 text
->layout_area
.height
);
1166 SWFDEC_AS_NATIVE (104, 101, swfdec_text_field_movie_getTextFormat
)
1168 swfdec_text_field_movie_getTextFormat (SwfdecAsContext
*cx
,
1169 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1172 SwfdecTextFieldMovie
*text
;
1173 SwfdecTextFormat
*format
;
1177 const SwfdecTextAttributes
*attr
;
1178 gsize start
, end
, length
;
1180 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1182 string
= swfdec_text_buffer_get_text (text
->text
);
1183 length
= g_utf8_strlen (string
, -1);
1185 format
= SWFDEC_TEXT_FORMAT (swfdec_text_format_new (cx
));
1186 SWFDEC_AS_VALUE_SET_OBJECT (ret
, SWFDEC_AS_OBJECT (format
));
1192 val
= swfdec_as_value_to_integer (cx
, &argv
[0]);
1193 start
= MAX (val
, 0);
1194 start
= MIN (start
, length
);
1196 if (val
< 0) { // fail
1199 end
= MIN (start
+ 1, length
);
1202 val
= swfdec_as_value_to_integer (cx
, &argv
[1]);
1204 end
= CLAMP (end
, start
, length
);
1211 start
= g_utf8_offset_to_pointer (string
, start
) - string
;
1212 end
= g_utf8_offset_to_pointer (string
, end
) - string
;
1213 mask
= swfdec_text_buffer_get_unique (text
->text
, start
, end
- start
);
1214 attr
= swfdec_text_buffer_get_attributes (text
->text
, start
);
1215 swfdec_text_attributes_copy (&format
->attr
, attr
, mask
);
1216 format
->values_set
= mask
;
1219 SWFDEC_AS_NATIVE (104, 100, swfdec_text_field_movie_replaceSel
)
1221 swfdec_text_field_movie_replaceSel (SwfdecAsContext
*cx
,
1222 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1225 SWFDEC_STUB ("TextField.replaceSel");
1228 SWFDEC_AS_NATIVE (104, 107, swfdec_text_field_movie_replaceText
)
1230 swfdec_text_field_movie_replaceText (SwfdecAsContext
*cx
,
1231 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1234 SwfdecTextFieldMovie
*text
;
1235 int start_index
, end_index
;
1236 const char *string
, *str
;
1239 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "iis", &start_index
,
1242 if (start_index
< 0)
1244 if (end_index
< start_index
)
1246 /* if there was a style sheet set when setting the text, modifications are
1248 if (text
->style_sheet_input
)
1251 string
= swfdec_text_buffer_get_text (text
->text
);
1252 start
= end
= g_utf8_strlen (string
, -1);
1253 start
= MIN ((gsize
) start_index
, start
);
1254 end
= MIN ((gsize
) end_index
, end
);
1255 start
= g_utf8_offset_to_pointer (string
, start
) - string
;
1256 end
= g_utf8_offset_to_pointer (string
, end
) - string
;
1258 /* anyone explain to me why Flash 7 has this special case plz */
1259 if (end
> start
&& (str
!= SWFDEC_AS_STR_EMPTY
|| cx
->version
!= 7))
1260 swfdec_text_buffer_delete_text (text
->text
, start
, end
- start
);
1262 swfdec_text_buffer_insert_text (text
->text
, start
, str
);
1263 /* yes, modifying text changes the default format */
1264 swfdec_text_buffer_set_default_attributes (text
->text
,
1265 swfdec_text_buffer_get_attributes (text
->text
, 0),
1266 SWFDEC_TEXT_ATTRIBUTES_MASK
);
1270 SWFDEC_AS_NATIVE (104, 201, swfdec_text_field_movie_getFontList
)
1272 swfdec_text_field_movie_getFontList (SwfdecAsContext
*cx
,
1273 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1276 SwfdecAsArray
*array
;
1278 PangoFontFamily
**families
;
1281 pango_font_map_list_families (pango_cairo_font_map_get_default (),
1282 &families
, &n_families
);
1284 array
= SWFDEC_AS_ARRAY (swfdec_as_array_new (cx
));
1285 for (i
= 0; i
< n_families
; i
++) {
1286 SWFDEC_AS_VALUE_SET_STRING (&val
, swfdec_as_context_get_string (cx
,
1287 pango_font_family_get_name (families
[i
])));
1288 swfdec_as_array_push (array
, &val
);
1290 SWFDEC_AS_VALUE_SET_STRING (&val
, SWFDEC_AS_STR_Sans
);
1291 swfdec_as_array_push (array
, &val
);
1292 SWFDEC_AS_VALUE_SET_STRING (&val
, SWFDEC_AS_STR_Serif
);
1293 swfdec_as_array_push (array
, &val
);
1294 SWFDEC_AS_VALUE_SET_STRING (&val
, SWFDEC_AS_STR_Monospace
);
1295 swfdec_as_array_push (array
, &val
);
1299 SWFDEC_AS_VALUE_SET_OBJECT (ret
, SWFDEC_AS_OBJECT (array
));
1302 SWFDEC_AS_NATIVE (104, 106, swfdec_text_field_movie_getDepth
)
1304 swfdec_text_field_movie_getDepth (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
1305 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
1307 SwfdecTextFieldMovie
*text
;
1309 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1311 swfdec_as_value_set_integer (cx
, rval
, SWFDEC_MOVIE (text
)->depth
);
1314 SWFDEC_AS_NATIVE (104, 103, swfdec_text_field_movie_removeTextField
)
1316 swfdec_text_field_movie_removeTextField (SwfdecAsContext
*cx
,
1317 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1318 SwfdecAsValue
*rval
)
1320 SwfdecTextFieldMovie
*text
;
1323 SWFDEC_AS_CHECK (SWFDEC_TYPE_TEXT_FIELD_MOVIE
, &text
, "");
1325 movie
= SWFDEC_MOVIE (text
);
1326 if (swfdec_depth_classify (movie
->depth
) == SWFDEC_DEPTH_CLASS_DYNAMIC
)
1327 swfdec_movie_remove (movie
);
1331 * Creating TextFields
1333 SWFDEC_AS_NATIVE (104, 200, swfdec_text_field_movie_createTextField
)
1335 swfdec_text_field_movie_createTextField (SwfdecAsContext
*cx
,
1336 SwfdecAsObject
*object
, guint argc
, SwfdecAsValue
*argv
,
1337 SwfdecAsValue
*rval
)
1339 SwfdecMovie
*movie
, *parent
;
1340 SwfdecTextField
*edittext
;
1341 int depth
, x
, y
, width
, height
;
1343 SwfdecAsFunction
*fun
;
1346 SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE
, &parent
, "siiiii", &name
, &depth
, &x
, &y
, &width
, &height
);
1347 width
= ABS (width
);
1348 height
= ABS (height
);
1350 edittext
= g_object_new (SWFDEC_TYPE_TEXT_FIELD
, NULL
);
1351 edittext
->html
= FALSE
;
1352 edittext
->editable
= FALSE
;
1353 edittext
->password
= FALSE
;
1354 edittext
->selectable
= TRUE
;
1355 edittext
->font
= NULL
; // FIXME
1356 edittext
->word_wrap
= FALSE
;
1357 edittext
->multiline
= FALSE
;
1358 edittext
->auto_size
= SWFDEC_AUTO_SIZE_NONE
;
1359 edittext
->border
= FALSE
;
1360 edittext
->size
= 240; // FIXME: Correct?
1362 edittext
->input
= NULL
;
1363 edittext
->variable
= NULL
;
1364 edittext
->color
= 0;
1365 edittext
->align
= SWFDEC_TEXT_ALIGN_LEFT
;
1366 edittext
->left_margin
= 0;
1367 edittext
->right_margin
= 0;
1368 edittext
->indent
= 0;
1369 edittext
->leading
= 0;
1371 SWFDEC_GRAPHIC (edittext
)->extents
.x0
= 0;
1372 SWFDEC_GRAPHIC (edittext
)->extents
.x1
= SWFDEC_DOUBLE_TO_TWIPS (width
);
1373 SWFDEC_GRAPHIC (edittext
)->extents
.y0
= 0;
1374 SWFDEC_GRAPHIC (edittext
)->extents
.y1
= SWFDEC_DOUBLE_TO_TWIPS (height
);
1376 movie
= swfdec_movie_find (parent
, depth
);
1378 swfdec_movie_remove (movie
);
1380 movie
= swfdec_movie_new (SWFDEC_PLAYER (cx
), depth
, parent
, parent
->resource
,
1381 SWFDEC_GRAPHIC (edittext
), name
);
1382 g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (movie
));
1383 g_object_unref (edittext
);
1385 swfdec_movie_begin_update_matrix (movie
);
1386 movie
->matrix
.x0
= SWFDEC_DOUBLE_TO_TWIPS (x
);
1387 movie
->matrix
.y0
= SWFDEC_DOUBLE_TO_TWIPS (y
);
1388 movie
->modified
= TRUE
;
1389 swfdec_movie_end_update_matrix (movie
);
1391 swfdec_movie_initialize (movie
);
1392 swfdec_movie_update (movie
);
1394 swfdec_as_object_get_variable (cx
->global
, SWFDEC_AS_STR_TextField
, &val
);
1395 if (!SWFDEC_AS_VALUE_IS_OBJECT (&val
))
1397 fun
= (SwfdecAsFunction
*) SWFDEC_AS_VALUE_GET_OBJECT (&val
);
1398 if (!SWFDEC_IS_AS_FUNCTION (fun
))
1401 /* set initial variables */
1402 if (swfdec_as_object_get_variable (SWFDEC_AS_OBJECT (fun
),
1403 SWFDEC_AS_STR_prototype
, &val
)) {
1404 swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie
),
1405 SWFDEC_AS_STR___proto__
, &val
,
1406 SWFDEC_AS_VARIABLE_HIDDEN
| SWFDEC_AS_VARIABLE_PERMANENT
);
1408 SWFDEC_AS_VALUE_SET_OBJECT (&val
, SWFDEC_AS_OBJECT (fun
));
1409 if (cx
->version
< 7) {
1410 swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie
),
1411 SWFDEC_AS_STR_constructor
, &val
, SWFDEC_AS_VARIABLE_HIDDEN
);
1413 swfdec_as_object_set_variable_and_flags (SWFDEC_AS_OBJECT (movie
),
1414 SWFDEC_AS_STR___constructor__
, &val
,
1415 SWFDEC_AS_VARIABLE_HIDDEN
| SWFDEC_AS_VARIABLE_VERSION_6_UP
);
1417 swfdec_as_function_call_full (fun
, SWFDEC_AS_OBJECT (movie
), TRUE
, NULL
,
1418 0, NULL
, cx
->version
> 7 ? rval
: &val
);
1422 swfdec_text_field_movie_init_properties (SwfdecAsContext
*cx
)
1425 SwfdecAsObject
*object
, *proto
;
1427 // FIXME: We should only initialize if the prototype Object has not been
1428 // initialized by any object's constructor with native properties
1429 // (TextField, TextFormat, XML, XMLNode at least)
1431 g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx
));
1433 swfdec_as_object_get_variable (cx
->global
, SWFDEC_AS_STR_TextField
, &val
);
1434 if (!SWFDEC_AS_VALUE_IS_OBJECT (&val
))
1436 object
= SWFDEC_AS_VALUE_GET_OBJECT (&val
);
1437 swfdec_as_object_get_variable (object
, SWFDEC_AS_STR_prototype
, &val
);
1438 if (!SWFDEC_AS_VALUE_IS_OBJECT (&val
))
1440 proto
= SWFDEC_AS_VALUE_GET_OBJECT (&val
);
1443 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_text
,
1444 swfdec_text_field_movie_do_get_text
,
1445 swfdec_text_field_movie_do_set_text
);
1446 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_html
,
1447 swfdec_text_field_movie_get_html
, swfdec_text_field_movie_set_html
);
1448 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_htmlText
,
1449 swfdec_text_field_movie_get_htmlText
,
1450 swfdec_text_field_movie_set_htmlText
);
1451 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_length
,
1452 swfdec_text_field_movie_get_length
,
1453 swfdec_text_field_movie_set_readonly
);
1456 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_condenseWhite
,
1457 swfdec_text_field_movie_get_condenseWhite
,
1458 swfdec_text_field_movie_set_condenseWhite
);
1459 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_maxChars
,
1460 swfdec_text_field_movie_get_maxChars
,
1461 swfdec_text_field_movie_set_maxChars
);
1462 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_multiline
,
1463 swfdec_text_field_movie_get_multiline
,
1464 swfdec_text_field_movie_set_multiline
);
1465 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_restrict
,
1466 swfdec_text_field_movie_get_restrict
,
1467 swfdec_text_field_movie_set_restrict
);
1468 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_selectable
,
1469 swfdec_text_field_movie_get_selectable
,
1470 swfdec_text_field_movie_set_selectable
);
1471 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_type
,
1472 swfdec_text_field_movie_do_get_type
,
1473 swfdec_text_field_movie_do_set_type
);
1474 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_variable
,
1475 swfdec_text_field_movie_do_get_variable
,
1476 swfdec_text_field_movie_do_set_variable
);
1479 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_textHeight
,
1480 swfdec_text_field_movie_get_textHeight
,
1481 swfdec_text_field_movie_set_readonly
);
1482 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_textWidth
,
1483 swfdec_text_field_movie_get_textWidth
,
1484 swfdec_text_field_movie_set_readonly
);
1486 // border & background
1487 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_background
,
1488 swfdec_text_field_movie_get_background
,
1489 swfdec_text_field_movie_set_background
);
1490 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_backgroundColor
,
1491 swfdec_text_field_movie_get_backgroundColor
,
1492 swfdec_text_field_movie_set_backgroundColor
);
1493 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_border
,
1494 swfdec_text_field_movie_get_border
, swfdec_text_field_movie_set_border
);
1495 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_borderColor
,
1496 swfdec_text_field_movie_get_borderColor
,
1497 swfdec_text_field_movie_set_borderColor
);
1500 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_bottomScroll
,
1501 swfdec_text_field_movie_get_bottomScroll
,
1502 swfdec_text_field_movie_set_readonly
);
1503 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_hscroll
,
1504 swfdec_text_field_movie_do_get_hscroll
,
1505 swfdec_text_field_movie_do_set_hscroll
);
1506 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_maxhscroll
,
1507 swfdec_text_field_movie_get_maxhscroll
,
1508 swfdec_text_field_movie_set_readonly
);
1509 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_maxscroll
,
1510 swfdec_text_field_movie_get_maxscroll
,
1511 swfdec_text_field_movie_set_readonly
);
1512 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_mouseWheelEnabled
,
1513 swfdec_text_field_movie_get_mouseWheelEnabled
,
1514 swfdec_text_field_movie_set_mouseWheelEnabled
);
1515 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_scroll
,
1516 swfdec_text_field_movie_do_get_scroll
,
1517 swfdec_text_field_movie_do_set_scroll
);
1520 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_autoSize
,
1521 swfdec_text_field_movie_get_autoSize
,
1522 swfdec_text_field_movie_set_autoSize
);
1523 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_password
,
1524 swfdec_text_field_movie_get_password
,
1525 swfdec_text_field_movie_set_password
);
1526 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_wordWrap
,
1527 swfdec_text_field_movie_get_wordWrap
,
1528 swfdec_text_field_movie_set_wordWrap
);
1531 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_embedFonts
,
1532 swfdec_text_field_movie_get_embedFonts
,
1533 swfdec_text_field_movie_set_embedFonts
);
1534 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_styleSheet
,
1535 swfdec_text_field_movie_get_styleSheet
,
1536 swfdec_text_field_movie_set_styleSheet
);
1537 swfdec_as_object_add_native_variable (proto
, SWFDEC_AS_STR_textColor
,
1538 swfdec_text_field_movie_get_textColor
,
1539 swfdec_text_field_movie_set_textColor
);
1541 // TODO: menu, tabEnabled, tabIndex
1543 // Version 8 properties have ASnative numbers:
1544 // gridFitType, antiAliasType, thickness, sharpness and filters
1547 SWFDEC_AS_NATIVE (104, 0, swfdec_text_field_movie_construct
)
1549 swfdec_text_field_movie_construct (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
1550 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
1552 if (!cx
->frame
->construct
) {
1553 object
= swfdec_as_object_new_empty (cx
);
1554 swfdec_as_object_set_constructor_by_name (object
, SWFDEC_AS_STR_TextField
, NULL
);
1557 swfdec_text_field_movie_init_properties (cx
);
1559 // FIXME: do object.addListener (object);
1561 SWFDEC_AS_VALUE_SET_OBJECT (ret
, object
);