]> www.fi.muni.cz Git - evince.git/blob - dvi/dvilib/dl-dvi-program.hh
Updated Swedish translation.
[evince.git] / dvi / dvilib / dl-dvi-program.hh
1 #ifndef DL_DVI_PROGRAM_HH__
2 #define DL_DVI_PROGRAM_HH__
3
4 using namespace std;
5
6 #include <string>
7 #include <vector>
8
9 #include <iostream>
10
11 #include "dl-refcounted.hh"
12 #include "dl-dvi-runtime.hh"
13
14 namespace DviLib
15 {
16     class DviCommand : public RefCounted
17     {
18     public:
19         virtual void execute (DviRuntime& runtime) = 0;
20         virtual ~DviCommand() {};
21     };
22     
23     class AbstractDviProgram : public RefCounted
24     {
25     public:
26         virtual void execute (DviRuntime &runtime) = 0;
27         virtual ~AbstractDviProgram (void) {};
28     };
29     
30     class DviProgram : public AbstractDviProgram
31     {
32     public:
33         vector <DviCommand *> commands;
34         void add_command (DviCommand *cmd);
35         virtual void execute (DviRuntime& runtime);
36         virtual ~DviProgram (void);
37     };
38     
39     class DviCharCommand : public DviCommand
40     {
41     private:
42         uint c;
43         
44     public:
45         DviCharCommand (uint c_arg)
46         {
47             c = c_arg;
48         }
49         uint get_c (void) const { return c; }
50     };
51     
52     class DviPutCharCommand : public DviCharCommand
53     {
54     public:
55         DviPutCharCommand (uint ch) : DviCharCommand (ch) {};
56         virtual void execute (DviRuntime& runtime) 
57         {
58             runtime.put_char (get_c());
59         }
60     };
61     
62     class DviSetCharCommand : public DviCharCommand
63     {
64     public:
65         DviSetCharCommand (uint ch) : DviCharCommand (ch) {};
66         virtual void execute (DviRuntime& runtime) 
67         {
68             runtime.set_char (get_c());
69         }
70     };
71     
72     class DviRuleCommand : public DviCommand
73     {
74     private:
75         int h, w;
76         
77     public:
78         DviRuleCommand (int h_arg, int w_arg) : h(h_arg), w(w_arg) 
79         {
80 #if 0
81             std::cout << "rule cmd " << h << " " << w << std::endl;
82 #endif
83         }
84         int get_h (void) const { return h; }
85         int get_w (void) const { return w; }
86     };
87     
88     class DviPutRuleCommand : public DviRuleCommand
89     {
90     public:
91         DviPutRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
92         virtual void execute (DviRuntime& runtime) 
93         {
94             runtime.put_rule (get_h(), get_w());
95         }
96     };
97     
98     class DviSetRuleCommand : public DviRuleCommand
99     {
100     public:
101         DviSetRuleCommand (int h, int w) : DviRuleCommand (h, w) {};
102         virtual void execute (DviRuntime& runtime) 
103         {
104             runtime.set_rule (get_h(), get_w());
105         }
106     };
107     
108     class DviPushCommand : public DviCommand
109     {
110     public:
111         DviPushCommand () {};
112         virtual void execute (DviRuntime& runtime) 
113         {
114             runtime.push ();
115         }
116     };
117     
118     class DviPopCommand : public DviCommand
119     {
120     public:
121         DviPopCommand () {};
122         virtual void execute (DviRuntime& runtime) 
123         {
124             runtime.pop ();
125         }
126     };
127     
128     class DviMoveCommand : public DviCommand
129     {
130     private:
131         int len;
132         
133     public:
134         DviMoveCommand (int len_arg) : len (len_arg) {};
135         int get_len (void) { return len; }
136     };
137     
138     class DviRightCommand : public DviMoveCommand
139     {
140     public:
141         DviRightCommand (int len) : DviMoveCommand (len) 
142         {
143 #if 0
144             cout << "right command " << get_len() << endl;
145 #endif
146         };
147         virtual void execute (DviRuntime& runtime) 
148         {
149             runtime.right (get_len());
150         }
151     };
152     
153     class DviWCommand : public DviMoveCommand
154     {
155     public:
156         DviWCommand (int len) : DviMoveCommand (len) {};
157         virtual void execute (DviRuntime& runtime) 
158         {
159             runtime.w (get_len());
160         }
161     };
162     
163     class DviXCommand : public DviMoveCommand
164     {
165     public:
166         DviXCommand (int len) : DviMoveCommand (len) {};
167         virtual void execute (DviRuntime& runtime) 
168         {
169             runtime.x (get_len());
170         }
171     };
172     
173     class DviDownCommand : public DviMoveCommand
174     {
175     public:
176         DviDownCommand (int len) : DviMoveCommand (len) 
177         {
178 #if 0
179             cout << "down command " << get_len() << endl;
180 #endif
181         };
182         virtual void execute (DviRuntime& runtime) 
183         {
184             runtime.down (get_len());
185         }
186     };
187     
188     class DviYCommand : public DviMoveCommand
189     {
190     public:
191         DviYCommand (int len) : DviMoveCommand (len) {};
192         virtual void execute (DviRuntime& runtime) 
193         {
194             runtime.y (get_len());
195         }
196     };
197     
198     class DviZCommand : public DviMoveCommand
199     {
200     public:
201         DviZCommand (int len) : DviMoveCommand (len) {};
202         virtual void execute (DviRuntime& runtime) 
203         {
204             runtime.z (get_len());
205         }
206     };
207     
208     class DviFontNumCommand : public DviCommand
209     {
210     private:
211         int num;
212         
213     public:
214         DviFontNumCommand (int num_arg) : num (num_arg) {}
215         virtual void execute (DviRuntime& runtime)
216         {
217             runtime.font_num (num);
218         }
219     };
220     
221     class DviSpecialCommand : public DviCommand
222     {
223         string spc;
224     public:
225         DviSpecialCommand (string s) : spc (s) {};
226         virtual ~DviSpecialCommand () {};
227         virtual void execute (DviRuntime& runtime) 
228         {
229             runtime.special (spc);
230         }
231     };
232     
233     class DviWRepCommand : public DviCommand
234     {
235     public:
236         DviWRepCommand () {};
237         virtual void execute (DviRuntime& runtime) 
238         {
239             runtime.w_rep ();
240         }
241     };
242     
243     class DviXRepCommand : public DviCommand
244     {
245     public:
246         DviXRepCommand () {};
247         virtual void execute (DviRuntime& runtime) 
248         {
249             runtime.x_rep ();
250         }
251     };
252     
253     class DviYRepCommand : public DviCommand
254     {
255     public:
256         DviYRepCommand () {};
257         virtual void execute (DviRuntime& runtime) 
258         {
259             runtime.y_rep ();
260         }
261     };
262     
263     class DviZRepCommand : public DviCommand
264     {
265     public:
266         DviZRepCommand () {};
267         virtual void execute (DviRuntime& runtime) 
268         {
269             runtime.z_rep ();
270         }
271     };
272     
273 }
274 #endif // DL_DVI_PROGRAM_HH__