KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > gtk > PixmapEngineParser


1 /*
2  * @(#)PixmapEngineParser.java 1.19 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.java.swing.plaf.gtk;
9
10 import javax.swing.plaf.synth.SynthConstants JavaDoc;
11 import java.io.IOException JavaDoc;
12 import java.util.ArrayList JavaDoc;
13 import java.awt.Font JavaDoc;
14 import java.awt.Insets JavaDoc;
15
16 /**
17  * A parser for the "pixmap" engine sections in GTK rc theme files.
18  *
19  * @author Shannon Hickey
20  * @version 1.19 12/19/03
21  */

22 class PixmapEngineParser extends GTKEngineParser {
23
24     private static final int SYM_IMAGE = GTKScanner.TOKEN_LAST + 1;
25     private static final int SYM_FUNCTION = SYM_IMAGE + 1;
26     private static final int SYM_FILE = SYM_FUNCTION + 1;
27     private static final int SYM_STRETCH = SYM_FILE + 1;
28     private static final int SYM_RECOLORABLE = SYM_STRETCH + 1;
29     private static final int SYM_BORDER = SYM_RECOLORABLE + 1;
30     private static final int SYM_DETAIL = SYM_BORDER + 1;
31     private static final int SYM_STATE = SYM_DETAIL + 1;
32     private static final int SYM_SHADOW = SYM_STATE + 1;
33     private static final int SYM_GAP_SIDE = SYM_SHADOW + 1;
34     private static final int SYM_GAP_FILE = SYM_GAP_SIDE + 1;
35     private static final int SYM_GAP_BORDER = SYM_GAP_FILE + 1;
36     private static final int SYM_GAP_START_FILE = SYM_GAP_BORDER + 1;
37     private static final int SYM_GAP_START_BORDER = SYM_GAP_START_FILE + 1;
38     private static final int SYM_GAP_END_FILE = SYM_GAP_START_BORDER + 1;
39     private static final int SYM_GAP_END_BORDER = SYM_GAP_END_FILE + 1;
40     private static final int SYM_OVERLAY_FILE = SYM_GAP_END_BORDER + 1;
41     private static final int SYM_OVERLAY_BORDER = SYM_OVERLAY_FILE + 1;
42     private static final int SYM_OVERLAY_STRETCH = SYM_OVERLAY_BORDER + 1;
43     private static final int SYM_ARROW_DIRECTION = SYM_OVERLAY_STRETCH + 1;
44     private static final int SYM_ORIENTATION = SYM_ARROW_DIRECTION + 1;
45     private static final int SYM_D_HLINE = SYM_ORIENTATION + 1;
46     private static final int SYM_D_VLINE = SYM_D_HLINE + 1;
47     private static final int SYM_D_SHADOW = SYM_D_VLINE + 1;
48     private static final int SYM_D_POLYGON = SYM_D_SHADOW + 1;
49     private static final int SYM_D_ARROW = SYM_D_POLYGON + 1;
50     private static final int SYM_D_DIAMOND = SYM_D_ARROW + 1;
51     private static final int SYM_D_OVAL = SYM_D_DIAMOND + 1;
52     private static final int SYM_D_STRING = SYM_D_OVAL + 1;
53     private static final int SYM_D_BOX = SYM_D_STRING + 1;
54     private static final int SYM_D_FLAT_BOX = SYM_D_BOX + 1;
55     private static final int SYM_D_CHECK = SYM_D_FLAT_BOX + 1;
56     private static final int SYM_D_OPTION = SYM_D_CHECK + 1;
57     private static final int SYM_D_CROSS = SYM_D_OPTION + 1;
58     private static final int SYM_D_RAMP = SYM_D_CROSS + 1;
59     private static final int SYM_D_TAB = SYM_D_RAMP + 1;
60     private static final int SYM_D_SHADOW_GAP = SYM_D_TAB + 1;
61     private static final int SYM_D_BOX_GAP = SYM_D_SHADOW_GAP + 1;
62     private static final int SYM_D_EXTENSION = SYM_D_BOX_GAP + 1;
63     private static final int SYM_D_FOCUS = SYM_D_EXTENSION + 1;
64     private static final int SYM_D_SLIDER = SYM_D_FOCUS + 1;
65     private static final int SYM_D_ENTRY = SYM_D_SLIDER + 1;
66     private static final int SYM_D_HANDLE = SYM_D_ENTRY + 1;
67     private static final int SYM_D_STEPPER = SYM_D_HANDLE + 1;
68     private static final int SYM_TRUE = SYM_D_STEPPER + 1;
69     private static final int SYM_FALSE = SYM_TRUE + 1;
70     private static final int SYM_TOP = SYM_FALSE + 1;
71     private static final int SYM_UP = SYM_TOP + 1;
72     private static final int SYM_BOTTOM = SYM_UP + 1;
73     private static final int SYM_DOWN = SYM_BOTTOM + 1;
74     private static final int SYM_LEFT = SYM_DOWN + 1;
75     private static final int SYM_RIGHT = SYM_LEFT + 1;
76     private static final int SYM_NORMAL = SYM_RIGHT + 1;
77     private static final int SYM_ACTIVE = SYM_NORMAL + 1;
78     private static final int SYM_PRELIGHT = SYM_ACTIVE + 1;
79     private static final int SYM_SELECTED = SYM_PRELIGHT + 1;
80     private static final int SYM_INSENSITIVE = SYM_SELECTED + 1;
81     private static final int SYM_NONE = SYM_INSENSITIVE + 1;
82     private static final int SYM_IN = SYM_NONE + 1;
83     private static final int SYM_OUT = SYM_IN + 1;
84     private static final int SYM_ETCHED_IN = SYM_OUT + 1;
85     private static final int SYM_ETCHED_OUT = SYM_ETCHED_IN + 1;
86     private static final int SYM_HORIZONTAL = SYM_ETCHED_OUT + 1;
87     private static final int SYM_VERTICAL = SYM_HORIZONTAL + 1;
88
89     private static final int[] symbolVals = {
90         SYM_IMAGE, SYM_FUNCTION, SYM_FILE, SYM_STRETCH, SYM_RECOLORABLE,
91         SYM_BORDER, SYM_DETAIL, SYM_STATE, SYM_SHADOW, SYM_GAP_SIDE,
92         SYM_GAP_FILE, SYM_GAP_BORDER, SYM_GAP_START_FILE, SYM_GAP_START_BORDER,
93         SYM_GAP_END_FILE, SYM_GAP_END_BORDER, SYM_OVERLAY_FILE, SYM_OVERLAY_BORDER,
94         SYM_OVERLAY_STRETCH, SYM_ARROW_DIRECTION, SYM_ORIENTATION, SYM_D_HLINE,
95         SYM_D_VLINE, SYM_D_SHADOW, SYM_D_POLYGON, SYM_D_ARROW, SYM_D_DIAMOND,
96         SYM_D_OVAL, SYM_D_STRING, SYM_D_BOX, SYM_D_FLAT_BOX, SYM_D_CHECK,
97         SYM_D_OPTION, SYM_D_CROSS, SYM_D_RAMP, SYM_D_TAB, SYM_D_SHADOW_GAP,
98         SYM_D_BOX_GAP, SYM_D_EXTENSION, SYM_D_FOCUS, SYM_D_SLIDER, SYM_D_ENTRY,
99         SYM_D_HANDLE, SYM_D_STEPPER, SYM_TRUE, SYM_FALSE, SYM_TOP, SYM_UP,
100         SYM_BOTTOM, SYM_DOWN, SYM_LEFT, SYM_RIGHT, SYM_NORMAL, SYM_ACTIVE,
101         SYM_PRELIGHT, SYM_SELECTED, SYM_INSENSITIVE, SYM_NONE, SYM_IN, SYM_OUT,
102         SYM_ETCHED_IN, SYM_ETCHED_OUT, SYM_HORIZONTAL, SYM_VERTICAL
103     };
104
105     private static final String JavaDoc[] symbolNames = {
106         "image", // SYM_IMAGE
107
"function", // SYM_FUNCTION
108
"file", // SYM_FILE
109
"stretch", // SYM_STRETCH
110
"recolorable", // SYM_RECOLORABLE
111
"border", // SYM_BORDER
112
"detail", // SYM_DETAIL
113
"state", // SYM_STATE
114
"shadow", // SYM_SHADOW
115
"gap_side", // SYM_GAP_SIDE
116
"gap_file", // SYM_GAP_FILE
117
"gap_border", // SYM_GAP_BORDER
118
"gap_start_file", // SYM_GAP_START_FILE
119
"gap_start_border", // SYM_GAP_START_BORDER
120
"gap_end_file", // SYM_GAP_END_FILE
121
"gap_end_border", // SYM_GAP_END_BORDER
122
"overlay_file", // SYM_OVERLAY_FILE
123
"overlay_border", // SYM_OVERLAY_BORDER
124
"overlay_stretch", // SYM_OVERLAY_STRETCH
125
"arrow_direction", // SYM_ARROW_DIRECTION
126
"orientation", // SYM_ORIENTATION
127

128         "HLINE", // SYM_D_HLINE
129
"VLINE", // SYM_D_VLINE
130
"SHADOW", // SYM_D_SHADOW
131
"POLYGON", // SYM_D_POLYGON
132
"ARROW", // SYM_D_ARROW
133
"DIAMOND", // SYM_D_DIAMOND
134
"OVAL", // SYM_D_OVAL
135
"STRING", // SYM_D_STRING
136
"BOX", // SYM_D_BOX
137
"FLAT_BOX", // SYM_D_FLAT_BOX
138
"CHECK", // SYM_D_CHECK
139
"OPTION", // SYM_D_OPTION
140
"CROSS", // SYM_D_CROSS
141
"RAMP", // SYM_D_RAMP
142
"TAB", // SYM_D_TAB
143
"SHADOW_GAP", // SYM_D_SHADOW_GAP
144
"BOX_GAP", // SYM_D_BOX_GAP
145
"EXTENSION", // SYM_D_EXTENSION
146
"FOCUS", // SYM_D_FOCUS
147
"SLIDER", // SYM_D_SLIDER
148
"ENTRY", // SYM_D_ENTRY
149
"HANDLE", // SYM_D_HANDLE
150
"STEPPER", // SYM_D_STEPPER
151

152         "TRUE", // SYM_TRUE
153
"FALSE", // SYM_FALSE
154

155         "TOP", // SYM_TOP
156
"UP", // SYM_UP
157
"BOTTOM", // SYM_BOTTOM
158
"DOWN", // SYM_DOWN
159
"LEFT", // SYM_LEFT
160
"RIGHT", // SYM_RIGHT
161

162         "NORMAL", // SYM_NORMAL
163
"ACTIVE", // SYM_ACTIVE
164
"PRELIGHT", // SYM_PRELIGHT
165
"SELECTED", // SYM_SELECTED
166
"INSENSITIVE", // SYM_INSENSITIVE
167

168         "NONE", // SYM_NONE
169
"IN", // SYM_IN
170
"OUT", // SYM_OUT
171
"ETCHED_IN", // SYM_ETCHED_IN
172
"ETCHED_OUT", // SYM_ETCHED_OUT
173
"HORIZONTAL", // SYM_HORIZONTAL
174
"VERTICAL" // SYM_VERTICAL
175
};
176
177     private static class PixmapEngineInfo extends GTKParser.EngineInfo {
178
179         ArrayList JavaDoc pInfos = new ArrayList JavaDoc();
180
181         GTKStyle constructGTKStyle(GTKStyle.GTKStateInfo[] infoArray,
182                                    CircularIdentityList props,
183                                    Font JavaDoc font,
184                                    int xThickness,
185                                    int yThickness,
186                                    GTKStyle.GTKStockIconInfo[] stockArray) {
187
188             PixmapStyle.Info[] pInfoArray = null;
189             if (pInfos.size() != 0) {
190                 pInfoArray = new PixmapStyle.Info[pInfos.size()];
191                 pInfoArray = (PixmapStyle.Info[])pInfos.toArray(pInfoArray);
192             }
193
194             return new PixmapStyle(infoArray,
195                                    props,
196                                    font,
197                                    xThickness,
198                                    yThickness,
199                                    stockArray,
200                                    pInfoArray);
201         }
202     }
203
204     private GTKScanner scanner;
205     private GTKParser parser;
206     private PixmapEngineInfo engineInfo;
207
208     private void registerSymbolsIfNecessary() {
209         if (scanner.containsSymbol(symbolNames[0])) {
210             return;
211         }
212
213         for (int i = 0; i < symbolNames.length; i++) {
214             scanner.addSymbol(symbolNames[i], symbolVals[i]);
215         }
216     }
217
218     int parse(GTKScanner scanner,
219               GTKParser parser,
220               GTKParser.EngineInfo[] retVal) throws IOException JavaDoc {
221
222         this.scanner = scanner;
223         this.parser = parser;
224
225         if (retVal[0] == null) {
226             engineInfo = new PixmapEngineInfo();
227         } else {
228             engineInfo = (PixmapEngineInfo)retVal[0];
229         }
230
231         int oldScope = scanner.setScope(uniqueScopeID);
232         registerSymbolsIfNecessary();
233
234         PixmapStyle.Info info[] = new PixmapStyle.Info[1];
235
236         int token;
237
238         token = scanner.peekNextToken();
239         while (token != GTKScanner.TOKEN_RIGHT_CURLY) {
240             switch(token) {
241                 case SYM_IMAGE:
242                     token = parseImage(info);
243                     break;
244                 default:
245                     scanner.getToken();
246                     token = GTKScanner.TOKEN_RIGHT_CURLY;
247                     break;
248             }
249
250             if (token != GTKScanner.TOKEN_NONE) {
251                 return token;
252             }
253
254             engineInfo.pInfos.add(info[0]);
255
256             token = scanner.peekNextToken();
257         }
258
259         scanner.getToken();
260
261         retVal[0] = engineInfo;
262
263         scanner.setScope(oldScope);
264         return GTKScanner.TOKEN_NONE;
265     }
266
267     private int parseImage(PixmapStyle.Info[] retVal) throws IOException JavaDoc {
268         int token;
269
270         token = scanner.getToken();
271         if (token != SYM_IMAGE) {
272             return SYM_IMAGE;
273         }
274
275         token = scanner.getToken();
276         if (token != GTKScanner.TOKEN_LEFT_CURLY) {
277             return GTKScanner.TOKEN_LEFT_CURLY;
278         }
279
280         PixmapStyle.Info info = new PixmapStyle.Info();
281
282         // to hold the return value from parseFile
283
String JavaDoc[] fileName = new String JavaDoc[1];
284         
285         // to hold the return value from parseStretch
286
boolean[] stretch = new boolean[1];
287         
288         // to hold the return value from parseBorder
289
Insets JavaDoc[] insets = new Insets JavaDoc[1];
290
291         token = scanner.peekNextToken();
292         while (token != GTKScanner.TOKEN_RIGHT_CURLY) {
293             switch(token) {
294                 case SYM_FUNCTION:
295                     token = parseFunction(info);
296                     break;
297                 case SYM_RECOLORABLE:
298                     token = parseRecolorable(info);
299                     break;
300                 case SYM_DETAIL:
301                     token = parseDetail(info);
302                     break;
303                 case SYM_STATE:
304                     token = parseState(info);
305                     break;
306                 case SYM_SHADOW:
307                     token = parseShadow(info);
308                     break;
309                 case SYM_GAP_SIDE:
310                     token = parseGapSide(info);
311                     break;
312                 case SYM_ARROW_DIRECTION:
313                     token = parseArrowDirection(info);
314                     break;
315                 case SYM_ORIENTATION:
316                     token = parseOrientation(info);
317                     break;
318                 case SYM_FILE:
319                     token = parseFile(fileName);
320                     if (token == GTKScanner.TOKEN_NONE) {
321                         info.image = fileName[0];
322                     }
323                     break;
324                 case SYM_BORDER:
325                     token = parseBorder(insets);
326                     if (token == GTKScanner.TOKEN_NONE) {
327                         info.fileInsets = insets[0];
328                     }
329                     break;
330                 case SYM_STRETCH:
331                     token = parseStretch(stretch);
332                     if (token == GTKScanner.TOKEN_NONE) {
333                         info.stretch = stretch[0];
334                     }
335                     break;
336                 case SYM_GAP_FILE:
337                     token = parseFile(fileName);
338                     if (token == GTKScanner.TOKEN_NONE) {
339                         info.gapImage = fileName[0];
340                     }
341                     break;
342                 case SYM_GAP_BORDER:
343                     token = parseBorder(insets);
344                     if (token == GTKScanner.TOKEN_NONE) {
345                         info.gapInsets = insets[0];
346                     }
347                     break;
348                 case SYM_GAP_START_FILE:
349                     token = parseFile(fileName);
350                     if (token == GTKScanner.TOKEN_NONE) {
351                         info.gapStartImage = fileName[0];
352                     }
353                     break;
354                 case SYM_GAP_START_BORDER:
355                     token = parseBorder(insets);
356                     if (token == GTKScanner.TOKEN_NONE) {
357                         info.gapStartInsets = insets[0];
358                     }
359                     break;
360                 case SYM_GAP_END_FILE:
361                     token = parseFile(fileName);
362                     if (token == GTKScanner.TOKEN_NONE) {
363                         info.gapEndImage = fileName[0];
364                     }
365                     break;
366                 case SYM_GAP_END_BORDER:
367                     token = parseBorder(insets);
368                     if (token == GTKScanner.TOKEN_NONE) {
369                         info.gapEndInsets = insets[0];
370                     }
371                     break;
372                 case SYM_OVERLAY_FILE:
373                     token = parseFile(fileName);
374                     if (token == GTKScanner.TOKEN_NONE) {
375                         info.overlayImage = fileName[0];
376                     }
377                     break;
378                 case SYM_OVERLAY_BORDER:
379                     token = parseBorder(insets);
380                     if (token == GTKScanner.TOKEN_NONE) {
381                         info.overlayInsets = insets[0];
382                     }
383                     break;
384                 case SYM_OVERLAY_STRETCH:
385                     token = parseStretch(stretch);
386                     if (token == GTKScanner.TOKEN_NONE) {
387                         info.overlayStretch = stretch[0];
388                     }
389                     break;
390                 default:
391                     scanner.getToken();
392                     token = GTKScanner.TOKEN_RIGHT_CURLY;
393                     break;
394             }
395
396             if (token != GTKScanner.TOKEN_NONE) {
397                 return token;
398             }
399
400             token = scanner.peekNextToken();
401         }
402
403         token = scanner.getToken();
404         if (token != GTKScanner.TOKEN_RIGHT_CURLY) {
405             return GTKScanner.TOKEN_RIGHT_CURLY;
406         }
407
408         // PENDING(shannonh) - may want to do some validation of the
409
// info before we return it
410

411         retVal[0] = info;
412         return GTKScanner.TOKEN_NONE;
413     }
414
415     private int parseFunction(PixmapStyle.Info info) throws IOException JavaDoc {
416         int token;
417
418         token = scanner.getToken();
419         if (token != SYM_FUNCTION) {
420             return SYM_FUNCTION;
421         }
422
423         token = scanner.getToken();
424         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
425             return GTKScanner.TOKEN_EQUAL_SIGN;
426         }
427
428         token = scanner.getToken();
429         if (token >= SYM_D_HLINE && token <= SYM_D_STEPPER) {
430             info.setFunction(symbolNames[token - SYM_IMAGE]);
431         }
432         
433         // PENDING(shannonh) - should we complain if not a valid function?
434

435         return GTKScanner.TOKEN_NONE;
436     }
437
438     private int parseRecolorable(PixmapStyle.Info info) throws IOException JavaDoc {
439         int token;
440         
441         token = scanner.getToken();
442         if (token != SYM_RECOLORABLE) {
443             return SYM_RECOLORABLE;
444         }
445         
446         token = scanner.getToken();
447         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
448             return GTKScanner.TOKEN_EQUAL_SIGN;
449         }
450         
451         token = scanner.getToken();
452         if (token == SYM_TRUE) {
453             info.recolorable = true;
454         } else if (token == SYM_FALSE) {
455             info.recolorable = false;
456         } else {
457             return SYM_TRUE;
458         }
459         
460         return GTKScanner.TOKEN_NONE;
461     }
462     
463     private int parseDetail(PixmapStyle.Info info) throws IOException JavaDoc {
464         int token;
465         
466         token = scanner.getToken();
467         if (token != SYM_DETAIL) {
468             return SYM_DETAIL;
469         }
470         
471         token = scanner.getToken();
472         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
473             return GTKScanner.TOKEN_EQUAL_SIGN;
474         }
475         
476         token = scanner.getToken();
477         if (token != GTKScanner.TOKEN_STRING) {
478             return GTKScanner.TOKEN_STRING;
479         }
480
481         info.setDetail(scanner.currValue.stringVal);
482
483         return GTKScanner.TOKEN_NONE;
484     }
485
486     private int parseState(PixmapStyle.Info info) throws IOException JavaDoc {
487         int token;
488         
489         token = scanner.getToken();
490         if (token != SYM_STATE) {
491             return SYM_STATE;
492         }
493         
494         token = scanner.getToken();
495         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
496             return GTKScanner.TOKEN_EQUAL_SIGN;
497         }
498         
499         token = scanner.getToken();
500         switch(token) {
501             case SYM_NORMAL:
502                 info.componentState = SynthConstants.ENABLED;
503                 break;
504             case SYM_ACTIVE:
505                 info.componentState = SynthConstants.PRESSED;
506                 break;
507             case SYM_PRELIGHT:
508                 info.componentState = SynthConstants.MOUSE_OVER;
509                 break;
510             case SYM_SELECTED:
511                 info.componentState = SynthConstants.SELECTED;
512                 break;
513             case SYM_INSENSITIVE:
514                 info.componentState = SynthConstants.DISABLED;
515                 break;
516             default:
517                 return SYM_NORMAL;
518         }
519
520         return GTKScanner.TOKEN_NONE;
521     }
522
523     private int parseShadow(PixmapStyle.Info info) throws IOException JavaDoc {
524         int token;
525         
526         token = scanner.getToken();
527         if (token != SYM_SHADOW) {
528             return SYM_SHADOW;
529         }
530         
531         token = scanner.getToken();
532         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
533             return GTKScanner.TOKEN_EQUAL_SIGN;
534         }
535         
536         token = scanner.getToken();
537         switch(token) {
538             case SYM_NONE:
539                 info.shadow = GTKConstants.SHADOW_NONE;
540                 break;
541             case SYM_IN:
542                 info.shadow = GTKConstants.SHADOW_IN;
543                 break;
544             case SYM_OUT:
545                 info.shadow = GTKConstants.SHADOW_OUT;
546                 break;
547             case SYM_ETCHED_IN:
548                 info.shadow = GTKConstants.SHADOW_ETCHED_IN;
549                 break;
550             case SYM_ETCHED_OUT:
551                 info.shadow = GTKConstants.SHADOW_ETCHED_OUT;
552                 break;
553             default:
554                 return SYM_NONE;
555         }
556
557         return GTKScanner.TOKEN_NONE;
558     }
559
560     private int parseGapSide(PixmapStyle.Info info) throws IOException JavaDoc {
561         int token;
562         
563         token = scanner.getToken();
564         if (token != SYM_GAP_SIDE) {
565             return SYM_GAP_SIDE;
566         }
567         
568         token = scanner.getToken();
569         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
570             return GTKScanner.TOKEN_EQUAL_SIGN;
571         }
572         
573         token = scanner.getToken();
574         switch(token) {
575             case SYM_TOP:
576                 info.gapSide = GTKConstants.TOP;
577                 break;
578             case SYM_BOTTOM:
579                 info.gapSide = GTKConstants.BOTTOM;
580                 break;
581             case SYM_LEFT:
582                 info.gapSide = GTKConstants.LEFT;
583                 break;
584             case SYM_RIGHT:
585                 info.gapSide = GTKConstants.RIGHT;
586                 break;
587             default:
588                 return SYM_TOP;
589         }
590
591         return GTKScanner.TOKEN_NONE;
592     }
593
594     private int parseArrowDirection(PixmapStyle.Info info) throws IOException JavaDoc {
595         int token;
596         
597         token = scanner.getToken();
598         if (token != SYM_ARROW_DIRECTION) {
599             return SYM_ARROW_DIRECTION;
600         }
601         
602         token = scanner.getToken();
603         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
604             return GTKScanner.TOKEN_EQUAL_SIGN;
605         }
606         
607         token = scanner.getToken();
608         switch(token) {
609             case SYM_UP:
610                 info.arrowDirection = GTKConstants.ARROW_UP;
611                 break;
612             case SYM_DOWN:
613                 info.arrowDirection = GTKConstants.ARROW_DOWN;
614                 break;
615             case SYM_LEFT:
616                 info.arrowDirection = GTKConstants.ARROW_LEFT;
617                 break;
618             case SYM_RIGHT:
619                 info.arrowDirection = GTKConstants.ARROW_RIGHT;
620                 break;
621             default:
622                 return SYM_UP;
623         }
624
625         return GTKScanner.TOKEN_NONE;
626     }
627     
628     private int parseOrientation(PixmapStyle.Info info) throws IOException JavaDoc {
629         int token;
630         
631         token = scanner.getToken();
632         if (token != SYM_ORIENTATION) {
633             return SYM_ORIENTATION;
634         }
635         
636         token = scanner.getToken();
637         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
638             return GTKScanner.TOKEN_EQUAL_SIGN;
639         }
640         
641         token = scanner.getToken();
642         switch(token) {
643             case SYM_HORIZONTAL:
644                 info.orientation = GTKConstants.HORIZONTAL;
645                 break;
646             case SYM_VERTICAL:
647                 info.orientation = GTKConstants.VERTICAL;
648                 break;
649             default:
650                 return SYM_HORIZONTAL;
651         }
652         
653         return GTKScanner.TOKEN_NONE;
654     }
655
656     private int parseFile(String JavaDoc[] retVal) throws IOException JavaDoc {
657         int token;
658
659         token = scanner.getToken();
660         
661         token = scanner.getToken();
662         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
663             return GTKScanner.TOKEN_EQUAL_SIGN;
664         }
665         
666         token = scanner.getToken();
667         if (token != GTKScanner.TOKEN_STRING) {
668             return GTKScanner.TOKEN_STRING;
669         }
670
671         retVal[0] = parser.resolvePixmapPath(scanner.currValue.stringVal);
672
673         return GTKScanner.TOKEN_NONE;
674     }
675
676     private int parseStretch(boolean[] retVal) throws IOException JavaDoc {
677         int token;
678         
679         token = scanner.getToken();
680         
681         token = scanner.getToken();
682         if (token != GTKScanner.TOKEN_EQUAL_SIGN) {
683             return GTKScanner.TOKEN_EQUAL_SIGN;
684         }
685         
686         token = scanner.getToken();
687         switch(token) {
688             case SYM_TRUE:
689                 retVal[0] = true;
690                 break;
691             case SYM_FALSE:
692                 retVal[0] = false;
693                 break;
694             default:
695                 return SYM_TRUE;
696         }
697         
698         return GTKScanner.TOKEN_NONE;
699     }
700
701     private int parseBorder(Insets JavaDoc[] retVal) throws IOException JavaDoc {
702         int left = 0;
703         int right = 0;
704         int top = 0;
705         int bottom = 0;
706         
707         scanner.getToken();
708         
709         if (scanner.getToken() != GTKScanner.TOKEN_EQUAL_SIGN) {
710             return GTKScanner.TOKEN_EQUAL_SIGN;
711         }
712         
713         if (scanner.getToken() != GTKScanner.TOKEN_LEFT_CURLY) {
714             return GTKScanner.TOKEN_LEFT_CURLY;
715         }
716         
717         if (scanner.getToken() != GTKScanner.TOKEN_INT) {
718             return GTKScanner.TOKEN_INT;
719         }
720         
721         left = (int)scanner.currValue.longVal;
722         
723         if (scanner.getToken() != GTKScanner.TOKEN_COMMA) {
724             return GTKScanner.TOKEN_COMMA;
725         }
726         
727         if (scanner.getToken() != GTKScanner.TOKEN_INT) {
728             return GTKScanner.TOKEN_INT;
729         }
730         
731         right = (int)scanner.currValue.longVal;
732         
733         if (scanner.getToken() != GTKScanner.TOKEN_COMMA) {
734             return GTKScanner.TOKEN_COMMA;
735         }
736         
737         if (scanner.getToken() != GTKScanner.TOKEN_INT) {
738             return GTKScanner.TOKEN_INT;
739         }
740         
741         top = (int)scanner.currValue.longVal;
742         
743         if (scanner.getToken() != GTKScanner.TOKEN_COMMA) {
744             return GTKScanner.TOKEN_COMMA;
745         }
746         
747         if (scanner.getToken() != GTKScanner.TOKEN_INT) {
748             return GTKScanner.TOKEN_INT;
749         }
750         
751         bottom = (int)scanner.currValue.longVal;
752         
753         if (scanner.getToken() != GTKScanner.TOKEN_RIGHT_CURLY) {
754             return GTKScanner.TOKEN_RIGHT_CURLY;
755         }
756
757         retVal[0] = new Insets JavaDoc(top, left, bottom, right);
758
759         return GTKScanner.TOKEN_NONE;
760     }
761
762 }
763
Popular Tags