dump full ttf2pt1 command line to log.
[swftools.git] / swfs / keyboard_viewer.c
blobe90a84e3a3ba4a6ffa9592bd70575eec84b4fb57
1 /* keyboard_viewer.c
3 Creates the swf file keyboard_viewer.swf.
4 This can be used to navigate through frames using the keyboard (space,
5 cursor left, cursor right)
6 Notice that the movie has to clicked with the mouse once to get
7 navigation activated in most browsers.
9 Part of the swftools package.
11 Copyright (c) 2000, 2001 Matthias Kramm <kramm@quiss.org>
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
27 #include <stdio.h>
28 #include <fcntl.h>
29 #include <math.h>
30 #include "rfxswf.h"
32 TAG* tag;
34 #define SUBTITLES 1
36 int main (int argc,char ** argv)
37 { SWF swf;
38 RGBA rgb;
39 SRECT r;
40 LPSHAPE s;
41 MATRIX m;
42 ActionTAG*a1,*a2,*a3,*a4,*a5;
43 S32 width=1024,height = 768;
45 int f,i,ls1,fs1;
47 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
49 swf.fileVersion = 4; // make flash 4 compatible swf
50 swf.frameRate = 0x1900; // about 0x19 frames per second
52 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units
53 swf.movieSize.ymax = 20*height;
55 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
56 tag = swf.firstTag;
57 rgb.r = 0xff;
58 rgb.g = 0xff;
59 rgb.b = 0xff;
60 swf_SetRGB(tag,&rgb);
62 // initialize matrix
63 m.sx = 65536; //scale
64 m.sy = 65536;
65 m.r0 = 0; //rotate
66 m.r1 = 0;
67 m.tx = 0; //move
68 m.ty = 0;
70 /* the "viewport" object will be replaced by swfcombine
71 with the object to browse. It is placed at the
72 upper left corner (0,0), by setting m.tx and m.ty
73 to 0. Therefore, the buttons are "in" the viewport,
74 not above it*/
75 tag = swf_InsertTag(tag,ST_DEFINESPRITE);
76 swf_SetU16(tag, 23); //id
77 swf_SetU16(tag, 0); //frames
78 tag = swf_InsertTag(tag,ST_END);
79 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
80 m.tx = 0; //move
81 m.ty = 0;
82 swf_ObjectPlace(tag, 23, 1,&m,0,"viewport");
84 a1 = action_SetTarget(0, "viewport");
85 a1 = action_PreviousFrame(a1);
86 a1 = action_SetTarget(a1, "");
87 a1 = action_End(a1);
89 a2 = action_SetTarget(0, "viewport");
90 a2 = action_NextFrame(a2);
91 a2 = action_SetTarget(a2,"");
92 a2 = action_End(a2);
94 a3 = action_Stop(0);
95 a3 = action_SetTarget(a3,"viewport");
96 a3 = action_Stop(a3);
97 a3 = action_SetTarget(a3,"");
98 #ifdef SUBTITLES
99 a3 = action_PushString(a3,"/:subtitle");
100 a3 = action_PushString(a3,""); //reset variable
101 a3 = action_SetVariable(a3);
102 #endif
103 a3 = action_End(a3);
105 a4 = action_GetUrl(0, "lichtfarbe.html", "_this");
106 a4 = action_End(a4);
108 a5 = action_GetUrl(0, "phybas.html","_this"); // load html in this window
109 a5 = action_End(a5);
111 tag = swf_InsertTag(tag,ST_DEFINESHAPE);
112 swf_ShapeNew(&s); // create new shape instance
113 rgb.r = rgb.b = rgb.g = 0x00;
114 ls1 = swf_ShapeAddLineStyle(s,40,&rgb);
115 fs1 = swf_ShapeAddSolidFillStyle(s,&rgb);
116 swf_SetU16(tag,77);
117 r.xmin = 0;
118 r.ymin = 0;
119 r.xmax = 20*width;
120 r.ymax = 20*height;
121 swf_SetRect(tag,&r); // set shape bounds
122 swf_SetShapeHeader(tag,s); // write all styles to tag
124 swf_ShapeSetAll(tag,s,0,0,ls1,fs1,0); // move to (0,0), select linestyle ls1 and no fillstyle
125 /* SetLine coordinates are relative.
126 It's important that the start and end points match, otherwise
127 the Macromedia Flash player will crash. */
128 swf_ShapeSetLine(tag,s,20*width,0*height);
129 swf_ShapeSetLine(tag,s,0*width,20*height);
130 swf_ShapeSetLine(tag,s,-20*width,0*height);
131 swf_ShapeSetLine(tag,s,0*width,-20*height);
133 swf_ShapeSetEnd(tag); // finish drawing
134 swf_ShapeFree(s); // clean shape structure (which isn't needed anymore after writing the tag)
136 tag = swf_InsertTag(tag,ST_DEFINEBUTTON2);
137 swf_SetU16(tag,30); //id
138 swf_ButtonSetFlags(tag, 0); //menu=no
139 swf_ButtonSetRecord(tag,BS_HIT,77,1,NULL,NULL);
140 swf_SetU8(tag,0); // end of button records
142 swf_ButtonSetCondition(tag, BC_CURSORLEFT);
143 swf_ActionSet(tag,a1);
144 swf_ButtonSetCondition(tag, BC_CURSORRIGHT);
145 swf_ActionSet(tag,a2);
146 swf_ButtonSetCondition(tag, BC_SPACE);
147 swf_ActionSet(tag,a2);
148 swf_ButtonSetCondition(tag, BC_ESCAPE);
149 swf_ActionSet(tag,a4);
150 swf_ButtonSetCondition(tag, BC_ENTER);
151 swf_ActionSet(tag,a5);
153 swf_ButtonPostProcess(tag, 5); // don't forget!
156 tag = swf_InsertTag(tag,ST_DOACTION);
157 swf_ActionSet(tag,a3);
159 m.tx = 0; //move
160 m.ty = 0;
161 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
162 swf_ObjectPlace(tag, 30, 2,&m,0,0);
164 swf_ActionFree(a1);
165 swf_ActionFree(a2);
166 swf_ActionFree(a3);
167 swf_ActionFree(a4);
168 swf_ActionFree(a5);
172 #ifdef SUBTITLES
173 tag = swf_InsertTag(tag,ST_DEFINEFONT2); {
174 U8 data[] = {0x90, 0x00, 0x0f, 0x54, 0x69, 0x6d, 0x65, 0x73,
175 0x20, 0x4e, 0x65, 0x77, 0x20, 0x52, 0x6f, 0x6d,
176 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x00};
178 swf_SetU16(tag, 0x76); //id
179 swf_SetBlock(tag, data, sizeof(data));
181 tag = swf_InsertTag(tag,ST_DEFINEEDITTEXT); {
182 EditTextLayout layout;
183 layout.align = 0;
184 layout.leftmargin = 0;
185 layout.rightmargin = 0;
186 layout.indent = 0;
187 layout.leading = 0;
189 swf_SetU16(tag, 0x77);//id
190 r.xmin = 20*60;
191 r.xmax = r.xmin+ 826*20;
192 r.ymin = 0;
193 r.ymax = 20*80;
194 rgb.r = rgb.g = rgb.b = 0;
195 rgb.a = 255;
196 swf_SetEditText(tag, ET_MULTILINE|ET_READONLY, r, 0, &rgb, 0, 0x76, 20*40, &layout, "/:subtitle");
197 m.tx = m.ty = 0;
199 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
200 swf_ObjectPlace(tag, 0x77, 4,&m,0,0);
201 #endif
203 tag = swf_InsertTag(tag,ST_SHOWFRAME);
204 tag = swf_InsertTag(tag,ST_END);
206 f = open("keyboard_viewer.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
207 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
208 close(f);
210 swf_FreeTags(&swf); // cleanup
211 return 0;