refresh frame fix, dblclk proxy viewer fix, vicon refresh fix for awdw resize, fix...
[goodguy/history.git] / cinelerra-5.1 / guicast / test.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "bcsignals.h"
23 #include "cursors.h"
24 #include "guicast.h"
25 #include "keys.h"
26 #include "language.h"
27 #include "vframe.h"
28 #include <ctype.h>
29 #include <math.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <sys/types.h>
34 #include <sys/wait.h>
35 #include <unistd.h>
36
37
38 #define MAX_ARGS 32
39 #define BCTEXTLEN 1024
40
41
42 void thread_fork()
43 {
44         int filedes[2];
45         int pid;
46         char *command_line = "ls -l -s -S -r";
47         char *arguments[MAX_ARGS];
48         char path[BCTEXTLEN];
49         int total_arguments;
50         FILE *stdin_fd;
51         int pipe_stdin = 0;
52         char *path_ptr;
53         char *ptr = command_line;
54         char *argument_ptr;
55         char argument[BCTEXTLEN];
56
57
58         path_ptr = path;
59         while(*ptr != ' ' && *ptr != 0)
60         {
61                 *path_ptr++ = *ptr++;
62         }
63         *path_ptr = 0;
64
65         arguments[total_arguments] = new char[strlen(path) + 1];
66         strcpy(arguments[total_arguments], path);
67 //printf("%s\n", arguments[total_arguments]);
68         total_arguments++;
69         arguments[total_arguments] = 0;
70
71         while(*ptr != 0)
72         {
73                 ptr++;
74                 argument_ptr = argument;
75                 while(*ptr != ' ' && *ptr != 0)
76                 {
77                         *argument_ptr++ = *ptr++;
78                 }
79                 *argument_ptr = 0;
80 //printf("%s\n", argument);
81
82                 arguments[total_arguments] = new char[strlen(argument) + 1];
83                 strcpy(arguments[total_arguments], argument);
84                 total_arguments++;
85                 arguments[total_arguments] = 0;
86         }
87
88         pipe(filedes);
89         stdin_fd = fdopen(filedes[1], "w");
90
91         int new_pid = fork();
92
93         if(new_pid == 0)
94         {
95                 dup2(filedes[0], fileno(stdin));
96                 execvp(path, arguments);
97                 perror("execvp");
98         }
99         else
100         {
101                 pid = new_pid;
102                 int return_value;
103                 if(waitpid(pid, &return_value, WUNTRACED) == -1)
104                 {
105                         perror("waitpid");
106                 }
107                 close(filedes[0]);
108                 close(filedes[1]);
109                 fclose(stdin_fd);
110                 printf("Finished.\n");
111         }
112
113
114
115
116 }
117
118
119 class TestWindow : public BC_Window
120 {
121 public:
122         TestWindow() : BC_Window("test",
123                                 0,
124                                 0,
125                                 320,
126                                 240,
127                                 -1,
128                                 -1,
129                                 0,
130                                 0,
131                                 1)
132         {
133                 current_cursor = 0;
134                 test_keypress = 1;
135         };
136
137         int close_event()
138         {
139                 set_done(0);
140                 return 1;
141         };
142
143         int keypress_event()
144         {
145                 switch(get_keypress())
146                 {
147                         case UP:
148                                 current_cursor += 1;
149                                 if(current_cursor >= XC_num_glyphs) current_cursor = 0;
150                                 break;
151
152                         case DOWN:
153                                 current_cursor -= 1;
154                                 if(current_cursor <= 0) current_cursor = XC_num_glyphs - 1;
155                                 break;
156                 }
157                 printf("%d\n", current_cursor);
158                 set_cursor(current_cursor, 0, 1);
159 //set_cursor(TRANSPARENT_CURSOR);
160         }
161
162         int current_cursor;
163 };
164
165 int main(int argc, char *argv[])
166 {
167         new BC_Signals;
168         TestWindow window;
169         int angles[] = { 180, 0 };
170         float values[] = { 1, 0 };
171
172         window.add_tool(new BC_Pan(10,
173                 120,
174                 100,
175                 1,
176                 2,
177                 angles,
178                 -1,
179                 -1,
180                 values));
181         window.add_tool(new BC_TextBox(10, 10, 200, 5, _("Mary Egbert\nhad a little lamb.")));
182         BC_Title *title;
183         window.add_tool(title = new BC_Title(10, 210, _("Hello world")));
184         title->update("xyz");
185         window.show_window();
186
187 sleep(2);
188         title->update("abc");
189
190         window.run_window();
191
192 //      thread_fork();
193 }
194
195
196
197
198
199
200
201