1 | /* |
---|
2 | * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC. |
---|
3 | * ALL RIGHTS RESERVED |
---|
4 | */ |
---|
5 | /* |
---|
6 | * Motif Release 1.2 |
---|
7 | */ |
---|
8 | #ifdef REV_INFO |
---|
9 | #ifndef lint |
---|
10 | static char rcsid[] = "$RCSfile: WmResCvt.c,v $ $Revision: 1.1.1.1 $ $Date: 1997-03-25 09:12:23 $" |
---|
11 | #endif |
---|
12 | #endif |
---|
13 | /* |
---|
14 | * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */ |
---|
15 | |
---|
16 | /* |
---|
17 | * Included Files: |
---|
18 | */ |
---|
19 | |
---|
20 | #include "WmGlobal.h" |
---|
21 | #include "WmResNames.h" |
---|
22 | #include <ctype.h> |
---|
23 | #include <stdio.h> |
---|
24 | |
---|
25 | #ifndef NO_MULTIBYTE |
---|
26 | #include <stdlib.h> |
---|
27 | #endif |
---|
28 | |
---|
29 | #ifndef MOTIF_ONE_DOT_ONE |
---|
30 | #include <Xm/XmosP.h> |
---|
31 | #endif |
---|
32 | |
---|
33 | /* |
---|
34 | * include extern functions |
---|
35 | */ |
---|
36 | |
---|
37 | #include "WmResParse.h" |
---|
38 | |
---|
39 | /* |
---|
40 | * Function Declarations: |
---|
41 | */ |
---|
42 | |
---|
43 | unsigned char *NextToken (); |
---|
44 | long DecStrToL (); |
---|
45 | |
---|
46 | #ifdef _NO_PROTO |
---|
47 | void AddWmResourceConverters (); |
---|
48 | Boolean StringsAreEqual (); |
---|
49 | void WmCvtStringToCFocus (); |
---|
50 | void WmCvtStringToCDecor (); |
---|
51 | void WmCvtStringToCFunc (); |
---|
52 | void WmCvtStringToIDecor (); |
---|
53 | void WmCvtStringToIPlace (); |
---|
54 | void WmCvtStringToKFocus (); |
---|
55 | void WmCvtStringToSize (); |
---|
56 | void WmCvtStringToShowFeedback (); |
---|
57 | void WmCvtStringToUsePPosition (); |
---|
58 | #else /* _NO_PROTO */ |
---|
59 | void AddWmResourceConverters (void); |
---|
60 | void WmCvtStringToCFocus (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
61 | void WmCvtStringToCDecor (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
62 | void WmCvtStringToCFunc (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
63 | void WmCvtStringToIDecor (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
64 | void WmCvtStringToIPlace (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
65 | void WmCvtStringToKFocus (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
66 | void WmCvtStringToSize (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
67 | void WmCvtStringToShowFeedback (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
68 | void WmCvtStringToUsePPosition (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal); |
---|
69 | Boolean StringsAreEqual (unsigned char *pch1, unsigned char *pch2, int len); |
---|
70 | #endif /* _NO_PROTO */ |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | /*************************************<->************************************* |
---|
76 | * |
---|
77 | * AddWmResourceConverters (args) |
---|
78 | * |
---|
79 | * |
---|
80 | * Description: |
---|
81 | * ----------- |
---|
82 | * This function adds resource type converters for mwm specific resource |
---|
83 | * types to the X Toolkit collection. |
---|
84 | * |
---|
85 | * |
---|
86 | * Inputs: |
---|
87 | * ------ |
---|
88 | * XXinput = ... |
---|
89 | * |
---|
90 | * XXinput = ... |
---|
91 | * |
---|
92 | * |
---|
93 | * Outputs: |
---|
94 | * ------- |
---|
95 | * XXOutput = ... |
---|
96 | * |
---|
97 | * |
---|
98 | * Comments: |
---|
99 | * -------- |
---|
100 | * XXComments ... |
---|
101 | * |
---|
102 | *************************************<->***********************************/ |
---|
103 | |
---|
104 | #ifdef _NO_PROTO |
---|
105 | void AddWmResourceConverters () |
---|
106 | |
---|
107 | #else /* _NO_PROTO */ |
---|
108 | void AddWmResourceConverters (void) |
---|
109 | #endif /* _NO_PROTO */ |
---|
110 | { |
---|
111 | XtAddConverter (XtRString, WmRCFocusPolicy, (XtConverter)WmCvtStringToCFocus, NULL, 0); |
---|
112 | XtAddConverter (XtRString, WmRClientDecor, (XtConverter)WmCvtStringToCDecor, NULL, 0); |
---|
113 | XtAddConverter (XtRString, WmRClientFunction, (XtConverter)WmCvtStringToCFunc, NULL, |
---|
114 | 0); |
---|
115 | XtAddConverter (XtRString, WmRIconDecor, (XtConverter)WmCvtStringToIDecor, NULL, 0); |
---|
116 | XtAddConverter (XtRString, WmRIconPlacement, (XtConverter)WmCvtStringToIPlace, NULL, 0); |
---|
117 | XtAddConverter (XtRString, WmRKFocusPolicy, (XtConverter)WmCvtStringToKFocus, NULL, 0); |
---|
118 | XtAddConverter (XtRString, WmRSize, (XtConverter)WmCvtStringToSize, NULL, 0); |
---|
119 | XtAddConverter (XtRString, WmRShowFeedback, (XtConverter)WmCvtStringToShowFeedback, |
---|
120 | NULL, 0); |
---|
121 | XtAddConverter (XtRString, WmRUsePPosition, (XtConverter)WmCvtStringToUsePPosition, |
---|
122 | NULL, 0); |
---|
123 | |
---|
124 | } /* END OF FUNCTION AddWmResourceConverters */ |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | /*************************************<->************************************* |
---|
129 | * |
---|
130 | * WmCvtStringToCFocus (args, numArgs, fromVal, toVal) |
---|
131 | * |
---|
132 | * |
---|
133 | * Description: |
---|
134 | * ----------- |
---|
135 | * This function converts a string to a colormap focus policy description. |
---|
136 | * |
---|
137 | * |
---|
138 | * Inputs: |
---|
139 | * ------ |
---|
140 | * args = additional XrmValue arguments to the converter - NULL here |
---|
141 | * |
---|
142 | * numArgs = number of XrmValue arguments - 0 here |
---|
143 | * |
---|
144 | * fromVal = resource value to convert |
---|
145 | * |
---|
146 | * |
---|
147 | * Outputs: |
---|
148 | * ------- |
---|
149 | * toVal = descriptor to use to return converted value |
---|
150 | * |
---|
151 | *************************************<->***********************************/ |
---|
152 | |
---|
153 | #ifdef _NO_PROTO |
---|
154 | void WmCvtStringToCFocus (args, numArgs, fromVal, toVal) |
---|
155 | |
---|
156 | XrmValue * args; |
---|
157 | Cardinal numArgs; |
---|
158 | XrmValue * fromVal; |
---|
159 | XrmValue * toVal; |
---|
160 | #else /* _NO_PROTO */ |
---|
161 | void WmCvtStringToCFocus (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
162 | #endif /* _NO_PROTO */ |
---|
163 | { |
---|
164 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
165 | unsigned char *pchNext; |
---|
166 | int len; |
---|
167 | static int cval; |
---|
168 | Boolean fHit = False; |
---|
169 | |
---|
170 | /* |
---|
171 | * Colormap focus policies: |
---|
172 | */ |
---|
173 | |
---|
174 | #define CMAP_FOCUS_EXPLICIT_STR (unsigned char *)"explicit" |
---|
175 | #define CMAP_FOCUS_KEYBOARD_STR (unsigned char *)"keyboard" |
---|
176 | #define CMAP_FOCUS_POINTER_STR (unsigned char *)"pointer" |
---|
177 | |
---|
178 | |
---|
179 | /* |
---|
180 | * Convert the colormap focus policy resource value: |
---|
181 | */ |
---|
182 | |
---|
183 | if (*pch && NextToken (pch, &len, &pchNext)) |
---|
184 | { |
---|
185 | if ((*pch == 'E') || (*pch == 'e')) |
---|
186 | { |
---|
187 | if (StringsAreEqual (pch, CMAP_FOCUS_EXPLICIT_STR, len)) |
---|
188 | { |
---|
189 | cval = CMAP_FOCUS_EXPLICIT; |
---|
190 | fHit = True; |
---|
191 | } |
---|
192 | } |
---|
193 | |
---|
194 | else if ((*pch == 'K') || (*pch == 'k')) |
---|
195 | { |
---|
196 | if (StringsAreEqual (pch, CMAP_FOCUS_KEYBOARD_STR, len)) |
---|
197 | { |
---|
198 | cval = CMAP_FOCUS_KEYBOARD; |
---|
199 | fHit = True; |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | else if ((*pch == 'P') || (*pch == 'p')) |
---|
204 | { |
---|
205 | if (StringsAreEqual (pch, CMAP_FOCUS_POINTER_STR, len)) |
---|
206 | { |
---|
207 | cval = CMAP_FOCUS_POINTER; |
---|
208 | fHit = True; |
---|
209 | } |
---|
210 | } |
---|
211 | } |
---|
212 | |
---|
213 | if (!fHit) |
---|
214 | { |
---|
215 | cval = CMAP_FOCUS_KEYBOARD; |
---|
216 | } |
---|
217 | |
---|
218 | |
---|
219 | (*toVal).size = sizeof (int); |
---|
220 | (*toVal).addr = (caddr_t)&cval; |
---|
221 | |
---|
222 | |
---|
223 | } /* END OF FUNCTION WmCvtStringToCFocus */ |
---|
224 | |
---|
225 | |
---|
226 | |
---|
227 | /*************************************<->************************************* |
---|
228 | * |
---|
229 | * WmCvtStringToCDecor (args, numArgs, fromVal, toVal) |
---|
230 | * |
---|
231 | * |
---|
232 | * Description: |
---|
233 | * ----------- |
---|
234 | * This function converts a string to a mwm client window frame decoration |
---|
235 | * description. |
---|
236 | * |
---|
237 | * |
---|
238 | * Inputs: |
---|
239 | * ------ |
---|
240 | * args = NULL (don't care) |
---|
241 | * |
---|
242 | * numArgs = 0 (don't care) |
---|
243 | * |
---|
244 | * fromVal = resource value to convert |
---|
245 | * |
---|
246 | * |
---|
247 | * Outputs: |
---|
248 | * ------- |
---|
249 | * toVal = descriptor to use to return converted value |
---|
250 | * |
---|
251 | * |
---|
252 | * Comments: |
---|
253 | * -------- |
---|
254 | * o Accepts the following syntax: |
---|
255 | * |
---|
256 | * CDecor ::= [sign] decor_spec [decor_spec ...] |
---|
257 | * |
---|
258 | * sign ::= ['+' | '-'] |
---|
259 | * |
---|
260 | * decor_spec ::= [sign] decor_name |
---|
261 | * |
---|
262 | * decor_name ::= "all" | "none" | "title" | "titlebar" | |
---|
263 | * "menu" | "minimize" | "maximize" | "resize" |
---|
264 | * |
---|
265 | *************************************<->***********************************/ |
---|
266 | |
---|
267 | #ifdef _NO_PROTO |
---|
268 | void WmCvtStringToCDecor (args, numArgs, fromVal, toVal) |
---|
269 | |
---|
270 | XrmValue *args; |
---|
271 | Cardinal numArgs; |
---|
272 | XrmValue *fromVal; |
---|
273 | XrmValue *toVal; |
---|
274 | #else /* _NO_PROTO */ |
---|
275 | void WmCvtStringToCDecor (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
276 | #endif /* _NO_PROTO */ |
---|
277 | { |
---|
278 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
279 | unsigned char *pchNext; |
---|
280 | int len; |
---|
281 | static int cval; |
---|
282 | Boolean fHit = False; |
---|
283 | Boolean fAddNext = True; |
---|
284 | /* |
---|
285 | * Client decoration parts: |
---|
286 | */ |
---|
287 | |
---|
288 | #define WM_DECOR_ALL_STR (unsigned char *)"all" |
---|
289 | #define WM_DECOR_NONE_STR (unsigned char *)"none" |
---|
290 | #define WM_DECOR_BORDER_STR (unsigned char *)"border" |
---|
291 | #define WM_DECOR_RESIZEH_STR (unsigned char *)"resizeh" |
---|
292 | #define WM_DECOR_TITLE_STR (unsigned char *)"title" |
---|
293 | #define WM_DECOR_TITLEBAR_STR (unsigned char *)"titlebar" |
---|
294 | #define WM_DECOR_MINIMIZE_STR (unsigned char *)"minimize" |
---|
295 | #define WM_DECOR_MAXIMIZE_STR (unsigned char *)"maximize" |
---|
296 | #define WM_DECOR_MENU_STR (unsigned char *)"menu" |
---|
297 | #define WM_DECOR_RESIZE_STR (unsigned char *)"resize" |
---|
298 | |
---|
299 | /* |
---|
300 | * Check first token. If '-' we subtract from all decoration. |
---|
301 | * Otherwise, we start with no decoration and add things in. |
---|
302 | */ |
---|
303 | if (*pch && |
---|
304 | (NextToken (pch, &len, &pchNext)) && |
---|
305 | (*pch == '-')) |
---|
306 | { |
---|
307 | cval = WM_DECOR_ALL; |
---|
308 | fHit = True; |
---|
309 | } |
---|
310 | else |
---|
311 | { |
---|
312 | cval = WM_DECOR_NONE; |
---|
313 | } |
---|
314 | |
---|
315 | |
---|
316 | while (*pch && NextToken(pch, &len, &pchNext)) |
---|
317 | { |
---|
318 | /* |
---|
319 | * Strip off "sign" if prepended to another token, and process |
---|
320 | * that token the next time through. |
---|
321 | */ |
---|
322 | |
---|
323 | if (*pch == '+') |
---|
324 | { |
---|
325 | if (len != 1) |
---|
326 | { |
---|
327 | pchNext = pch + 1; |
---|
328 | } |
---|
329 | fAddNext = TRUE; |
---|
330 | } |
---|
331 | |
---|
332 | else if (*pch == '-') |
---|
333 | { |
---|
334 | if (len != 1) |
---|
335 | { |
---|
336 | pchNext = pch + 1; |
---|
337 | } |
---|
338 | fAddNext = FALSE; |
---|
339 | } |
---|
340 | |
---|
341 | else if ((*pch == 'A') || (*pch == 'a')) |
---|
342 | { |
---|
343 | if (StringsAreEqual(pch, WM_DECOR_ALL_STR,len)) |
---|
344 | { |
---|
345 | cval = fAddNext ? (cval | WM_DECOR_ALL) : |
---|
346 | (cval & ~WM_DECOR_ALL); |
---|
347 | fHit = True; |
---|
348 | } |
---|
349 | } |
---|
350 | |
---|
351 | else if ((*pch == 'N') || (*pch == 'n')) |
---|
352 | { |
---|
353 | if (StringsAreEqual(pch, WM_DECOR_NONE_STR,len)) |
---|
354 | { |
---|
355 | /* don't bother adding or subtracting nothing */ |
---|
356 | fHit = True; |
---|
357 | } |
---|
358 | } |
---|
359 | |
---|
360 | else if ((*pch == 'T') || (*pch == 't')) |
---|
361 | { |
---|
362 | if (StringsAreEqual(pch, WM_DECOR_TITLE_STR,len)) |
---|
363 | { |
---|
364 | cval = fAddNext ? (cval | WM_DECOR_TITLE) : |
---|
365 | (cval & ~WM_DECOR_TITLEBAR); |
---|
366 | fHit = True; |
---|
367 | } |
---|
368 | else if (StringsAreEqual(pch, WM_DECOR_TITLEBAR_STR,len)) |
---|
369 | { |
---|
370 | cval = fAddNext ? (cval | WM_DECOR_TITLEBAR) : |
---|
371 | (cval & ~WM_DECOR_TITLEBAR); |
---|
372 | fHit = True; |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | else if ((*pch == 'M') || (*pch == 'm')) |
---|
377 | { |
---|
378 | if (StringsAreEqual(pch, WM_DECOR_MINIMIZE_STR,len)) |
---|
379 | { |
---|
380 | cval = fAddNext ? (cval | WM_DECOR_MINIMIZE) : |
---|
381 | (cval & ~MWM_DECOR_MINIMIZE); |
---|
382 | fHit = True; |
---|
383 | } |
---|
384 | else if (StringsAreEqual(pch, WM_DECOR_MAXIMIZE_STR,len)) |
---|
385 | { |
---|
386 | cval = fAddNext ? (cval | WM_DECOR_MAXIMIZE) : |
---|
387 | (cval & ~MWM_DECOR_MAXIMIZE); |
---|
388 | fHit = True; |
---|
389 | } |
---|
390 | else if (StringsAreEqual(pch, WM_DECOR_MENU_STR,len)) |
---|
391 | { |
---|
392 | cval = fAddNext ? (cval | WM_DECOR_SYSTEM) : |
---|
393 | (cval & ~MWM_DECOR_MENU); |
---|
394 | fHit = True; |
---|
395 | } |
---|
396 | } |
---|
397 | |
---|
398 | else if ((*pch == 'R') || (*pch == 'r')) |
---|
399 | { |
---|
400 | if (StringsAreEqual(pch, WM_DECOR_RESIZE_STR,len) || |
---|
401 | StringsAreEqual(pch, WM_DECOR_RESIZEH_STR,len)) |
---|
402 | { |
---|
403 | cval = fAddNext ? (cval | WM_DECOR_RESIZEH) : |
---|
404 | (cval & ~MWM_DECOR_RESIZEH); |
---|
405 | fHit = True; |
---|
406 | } |
---|
407 | } |
---|
408 | |
---|
409 | else if ((*pch == 'B') || (*pch == 'b')) |
---|
410 | { |
---|
411 | if (StringsAreEqual(pch, WM_DECOR_BORDER_STR,len)) |
---|
412 | { |
---|
413 | cval = fAddNext ? (cval | WM_DECOR_BORDER) : |
---|
414 | (cval & ~WM_DECOR_BORDER); |
---|
415 | fHit = True; |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | pch = pchNext; |
---|
420 | } |
---|
421 | |
---|
422 | if (!fHit) cval = WM_DECOR_ALL; |
---|
423 | |
---|
424 | (*toVal).size = sizeof (int); |
---|
425 | (*toVal).addr = (caddr_t) &cval; |
---|
426 | |
---|
427 | } /* END OF FUNCTION WmCvtStringToCDecor */ |
---|
428 | |
---|
429 | |
---|
430 | |
---|
431 | /*************************************<->************************************* |
---|
432 | * |
---|
433 | * WmCvtStringToCFunc (args, numArgs, fromVal, toVal) |
---|
434 | * |
---|
435 | * |
---|
436 | * Description: |
---|
437 | * ----------- |
---|
438 | * This function converts a string to a mwm client-applicable function |
---|
439 | * description. |
---|
440 | * |
---|
441 | * |
---|
442 | * Inputs: |
---|
443 | * ------ |
---|
444 | * args = NULL (don't care) |
---|
445 | * |
---|
446 | * numArgs = 0 (don't care) |
---|
447 | * |
---|
448 | * fromVal = resource value to convert |
---|
449 | * |
---|
450 | * |
---|
451 | * Outputs: |
---|
452 | * ------- |
---|
453 | * toVal = descriptor to use to return converted value |
---|
454 | * |
---|
455 | * |
---|
456 | * Comments: |
---|
457 | * -------- |
---|
458 | * o Accepts the following syntax: |
---|
459 | * |
---|
460 | * CFunc ::= [sign] func_spec [func_spec ...] |
---|
461 | * |
---|
462 | * sign ::= ['+' | '-'] |
---|
463 | * |
---|
464 | * func_spec ::= [sign] func_name |
---|
465 | * |
---|
466 | * func_name ::= "all" | "none" | "resize" | "move" | "minimize" | |
---|
467 | * "maximize" | "close" |
---|
468 | * |
---|
469 | *************************************<->***********************************/ |
---|
470 | |
---|
471 | #ifdef _NO_PROTO |
---|
472 | void WmCvtStringToCFunc (args, numArgs, fromVal, toVal) |
---|
473 | |
---|
474 | XrmValue *args; |
---|
475 | Cardinal numArgs; |
---|
476 | XrmValue *fromVal; |
---|
477 | XrmValue *toVal; |
---|
478 | #else /* _NO_PROTO */ |
---|
479 | void WmCvtStringToCFunc (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
480 | #endif /* _NO_PROTO */ |
---|
481 | { |
---|
482 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
483 | unsigned char *pchNext; |
---|
484 | int len; |
---|
485 | static int cval; |
---|
486 | Boolean fHit = False; |
---|
487 | Boolean fAddNext = True; |
---|
488 | |
---|
489 | /* |
---|
490 | * Client-applicable functions: |
---|
491 | */ |
---|
492 | |
---|
493 | #define WM_FUNC_ALL_STR (unsigned char *)"all" |
---|
494 | #define WM_FUNC_NONE_STR (unsigned char *)"none" |
---|
495 | #define WM_FUNC_RESIZE_STR (unsigned char *)"resize" |
---|
496 | #define WM_FUNC_MOVE_STR (unsigned char *)"move" |
---|
497 | #define WM_FUNC_MINIMIZE_STR (unsigned char *)"minimize" |
---|
498 | #define WM_FUNC_MAXIMIZE_STR (unsigned char *)"maximize" |
---|
499 | #define WM_FUNC_CLOSE_STR (unsigned char *)"close" |
---|
500 | |
---|
501 | /* |
---|
502 | * Check first token. If '-' we subtract from all functions. |
---|
503 | * Otherwise, we start with no functions and add things in. |
---|
504 | */ |
---|
505 | |
---|
506 | if (*pch && |
---|
507 | (NextToken (pch, &len, &pchNext)) && |
---|
508 | (*pch == '-')) |
---|
509 | { |
---|
510 | cval = WM_FUNC_ALL; |
---|
511 | fHit = True; |
---|
512 | } |
---|
513 | else |
---|
514 | { |
---|
515 | cval = WM_FUNC_NONE; |
---|
516 | } |
---|
517 | |
---|
518 | |
---|
519 | while (*pch && NextToken(pch, &len, &pchNext)) |
---|
520 | { |
---|
521 | /* |
---|
522 | * Strip off "sign" if prepended to another token, and process |
---|
523 | * that token the next time through. |
---|
524 | */ |
---|
525 | |
---|
526 | if (*pch == '+') |
---|
527 | { |
---|
528 | if (len != 1) |
---|
529 | { |
---|
530 | pchNext = pch + 1; |
---|
531 | } |
---|
532 | fAddNext = TRUE; |
---|
533 | } |
---|
534 | |
---|
535 | else if (*pch == '-') |
---|
536 | { |
---|
537 | if (len != 1) |
---|
538 | { |
---|
539 | pchNext = pch + 1; |
---|
540 | } |
---|
541 | fAddNext = FALSE; |
---|
542 | } |
---|
543 | |
---|
544 | else if ((*pch == 'A') || (*pch == 'a')) |
---|
545 | { |
---|
546 | if (StringsAreEqual(pch, WM_FUNC_ALL_STR,len)) |
---|
547 | { |
---|
548 | cval = fAddNext ? (cval | WM_FUNC_ALL) : |
---|
549 | (cval & ~WM_FUNC_ALL); |
---|
550 | fHit = True; |
---|
551 | } |
---|
552 | } |
---|
553 | |
---|
554 | else if ((*pch == 'N') || (*pch == 'n')) |
---|
555 | { |
---|
556 | if (StringsAreEqual(pch, WM_FUNC_NONE_STR,len)) |
---|
557 | { |
---|
558 | /* don't bother adding or subtracting nothing */ |
---|
559 | fHit = True; |
---|
560 | } |
---|
561 | } |
---|
562 | |
---|
563 | else if ((*pch == 'R') || (*pch == 'r')) |
---|
564 | { |
---|
565 | if (StringsAreEqual(pch, WM_FUNC_RESIZE_STR,len)) |
---|
566 | { |
---|
567 | cval = fAddNext ? (cval | MWM_FUNC_RESIZE) : |
---|
568 | (cval & ~MWM_FUNC_RESIZE); |
---|
569 | fHit = True; |
---|
570 | } |
---|
571 | } |
---|
572 | |
---|
573 | else if ((*pch == 'M') || (*pch == 'm')) |
---|
574 | { |
---|
575 | if (StringsAreEqual(pch, WM_FUNC_MINIMIZE_STR,len)) |
---|
576 | { |
---|
577 | cval = fAddNext ? (cval | MWM_FUNC_MINIMIZE) : |
---|
578 | (cval & ~MWM_FUNC_MINIMIZE); |
---|
579 | fHit = True; |
---|
580 | } |
---|
581 | else if (StringsAreEqual(pch, WM_FUNC_MAXIMIZE_STR,len)) |
---|
582 | { |
---|
583 | cval = fAddNext ? (cval | MWM_FUNC_MAXIMIZE) : |
---|
584 | (cval & ~MWM_FUNC_MAXIMIZE); |
---|
585 | fHit = True; |
---|
586 | } |
---|
587 | else if (StringsAreEqual(pch, WM_FUNC_MOVE_STR,len)) |
---|
588 | { |
---|
589 | cval = fAddNext ? (cval | MWM_FUNC_MOVE) : |
---|
590 | (cval & ~MWM_FUNC_MOVE); |
---|
591 | fHit = True; |
---|
592 | } |
---|
593 | } |
---|
594 | |
---|
595 | else if ((*pch == 'C') || (*pch == 'c')) |
---|
596 | { |
---|
597 | if (StringsAreEqual(pch, WM_FUNC_CLOSE_STR,len)) |
---|
598 | { |
---|
599 | cval = fAddNext ? (cval | MWM_FUNC_CLOSE) : |
---|
600 | (cval & ~MWM_FUNC_CLOSE); |
---|
601 | fHit = True; |
---|
602 | } |
---|
603 | } |
---|
604 | |
---|
605 | pch = pchNext; |
---|
606 | } |
---|
607 | |
---|
608 | if (!fHit) cval = WM_FUNC_ALL; |
---|
609 | |
---|
610 | (*toVal).size = sizeof (int); |
---|
611 | (*toVal).addr = (caddr_t) &cval; |
---|
612 | |
---|
613 | } /* END OF FUNCTION WmCvtStringToCFunc */ |
---|
614 | |
---|
615 | |
---|
616 | |
---|
617 | /*************************************<->************************************* |
---|
618 | * |
---|
619 | * WmCvtStringToIDecor (args, numArgs, fromVal, toVal) |
---|
620 | * |
---|
621 | * |
---|
622 | * Description: |
---|
623 | * ----------- |
---|
624 | * This function converts a string to an icon decoration description. |
---|
625 | * |
---|
626 | * |
---|
627 | * Inputs: |
---|
628 | * ------ |
---|
629 | * args = NULL (don't care) |
---|
630 | * |
---|
631 | * numArgs = 0 (don't care) |
---|
632 | * |
---|
633 | * fromVal = resource value to convert |
---|
634 | * |
---|
635 | * |
---|
636 | * Outputs: |
---|
637 | * ------- |
---|
638 | * toVal = descriptor to use to return converted value |
---|
639 | * |
---|
640 | *************************************<->***********************************/ |
---|
641 | |
---|
642 | #ifdef _NO_PROTO |
---|
643 | void WmCvtStringToIDecor (args, numArgs, fromVal, toVal) |
---|
644 | |
---|
645 | XrmValue *args; |
---|
646 | Cardinal numArgs; |
---|
647 | XrmValue *fromVal; |
---|
648 | XrmValue *toVal; |
---|
649 | #else /* _NO_PROTO */ |
---|
650 | void WmCvtStringToIDecor (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
651 | #endif /* _NO_PROTO */ |
---|
652 | { |
---|
653 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
654 | unsigned char *pchNext; |
---|
655 | int len; |
---|
656 | static long cval; |
---|
657 | Boolean fHit = False; |
---|
658 | |
---|
659 | /* |
---|
660 | * Icon decoration parts: |
---|
661 | */ |
---|
662 | |
---|
663 | #define ICON_DECOR_IMAGE_STR (unsigned char *)"image" |
---|
664 | #define ICON_DECOR_LABEL_STR (unsigned char *)"label" |
---|
665 | #define ICON_DECOR_ACTIVE_LABEL_STR (unsigned char *)"activelabel" |
---|
666 | |
---|
667 | |
---|
668 | /* |
---|
669 | * Convert the icon decoration resource value: |
---|
670 | */ |
---|
671 | |
---|
672 | cval = 0; |
---|
673 | |
---|
674 | while (*pch && NextToken (pch, &len, &pchNext)) |
---|
675 | { |
---|
676 | if ((*pch == 'A') || (*pch == 'a')) |
---|
677 | { |
---|
678 | if (StringsAreEqual (pch, ICON_DECOR_ACTIVE_LABEL_STR, len)) |
---|
679 | { |
---|
680 | cval |= ICON_ACTIVE_LABEL_PART; |
---|
681 | fHit = True; |
---|
682 | } |
---|
683 | } |
---|
684 | |
---|
685 | else if ((*pch == 'I') || (*pch == 'i')) |
---|
686 | { |
---|
687 | if (StringsAreEqual (pch, ICON_DECOR_IMAGE_STR, len)) |
---|
688 | { |
---|
689 | cval |= ICON_IMAGE_PART; |
---|
690 | fHit = True; |
---|
691 | } |
---|
692 | } |
---|
693 | |
---|
694 | else if ((*pch == 'L') || (*pch == 'l')) |
---|
695 | { |
---|
696 | if (StringsAreEqual (pch, ICON_DECOR_LABEL_STR, len)) |
---|
697 | { |
---|
698 | cval |= ICON_LABEL_PART; |
---|
699 | fHit = True; |
---|
700 | } |
---|
701 | } |
---|
702 | |
---|
703 | pch = pchNext; |
---|
704 | } |
---|
705 | |
---|
706 | /* |
---|
707 | * If we didn't match anything or only have the active label |
---|
708 | * (which is just a modifier) then give 'em the whole ball of wax. |
---|
709 | */ |
---|
710 | if (!fHit || cval == ICON_ACTIVE_LABEL_PART) |
---|
711 | { |
---|
712 | cval = ICON_LABEL_PART | ICON_IMAGE_PART | ICON_ACTIVE_LABEL_PART; |
---|
713 | } |
---|
714 | |
---|
715 | |
---|
716 | (*toVal).size = sizeof (long); |
---|
717 | (*toVal).addr = (caddr_t) &cval; |
---|
718 | |
---|
719 | } /* END OF FUNCTION WmCvtStringToIDecor */ |
---|
720 | |
---|
721 | |
---|
722 | |
---|
723 | /*************************************<->************************************* |
---|
724 | * |
---|
725 | * WmCvtStringToIPlace (args, numArgs, fromVal, toVal) |
---|
726 | * |
---|
727 | * |
---|
728 | * Description: |
---|
729 | * ----------- |
---|
730 | * This function converts a string to an icon placement scheme description. |
---|
731 | * |
---|
732 | * |
---|
733 | * Inputs: |
---|
734 | * ------ |
---|
735 | * args = NULL (don't care) |
---|
736 | * |
---|
737 | * numArgs = 0 (don't care) |
---|
738 | * |
---|
739 | * fromVal = resource value to convert |
---|
740 | * |
---|
741 | * |
---|
742 | * Outputs: |
---|
743 | * ------- |
---|
744 | * toVal = descriptor to use to return converted value |
---|
745 | * |
---|
746 | *************************************<->***********************************/ |
---|
747 | |
---|
748 | #ifdef _NO_PROTO |
---|
749 | void WmCvtStringToIPlace (args, numArgs, fromVal, toVal) |
---|
750 | |
---|
751 | XrmValue * args; |
---|
752 | Cardinal numArgs; |
---|
753 | XrmValue * fromVal; |
---|
754 | XrmValue * toVal; |
---|
755 | #else /* _NO_PROTO */ |
---|
756 | void WmCvtStringToIPlace (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
757 | #endif /* _NO_PROTO */ |
---|
758 | { |
---|
759 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
760 | unsigned char *pchNext; |
---|
761 | int len; |
---|
762 | static long cval; |
---|
763 | Boolean fPrimarySet = False; |
---|
764 | Boolean fSecondarySet = False; |
---|
765 | |
---|
766 | /* |
---|
767 | * Icon placement layout values: |
---|
768 | */ |
---|
769 | |
---|
770 | #define ICON_PLACE_BOTTOM_STR (unsigned char *)"bottom" |
---|
771 | #define ICON_PLACE_LEFT_STR (unsigned char *)"left" |
---|
772 | #define ICON_PLACE_RIGHT_STR (unsigned char *)"right" |
---|
773 | #define ICON_PLACE_TOP_STR (unsigned char *)"top" |
---|
774 | #define ICON_PLACE_TIGHT_STR (unsigned char *)"tight" |
---|
775 | |
---|
776 | |
---|
777 | /* |
---|
778 | * Convert the icon placement resource value: |
---|
779 | */ |
---|
780 | |
---|
781 | cval = 0; |
---|
782 | |
---|
783 | while (*pch && NextToken (pch, &len, &pchNext)) |
---|
784 | { |
---|
785 | if ((*pch == 'B') || (*pch == 'b')) |
---|
786 | { |
---|
787 | if (StringsAreEqual (pch, ICON_PLACE_BOTTOM_STR, len)) |
---|
788 | { |
---|
789 | if (!fPrimarySet) |
---|
790 | { |
---|
791 | cval |= ICON_PLACE_BOTTOM_PRIMARY; |
---|
792 | fPrimarySet = True; |
---|
793 | } |
---|
794 | else if (!fSecondarySet) |
---|
795 | { |
---|
796 | if (!(cval & |
---|
797 | (ICON_PLACE_BOTTOM_PRIMARY | ICON_PLACE_TOP_PRIMARY))) |
---|
798 | { |
---|
799 | cval |= ICON_PLACE_BOTTOM_SECONDARY; |
---|
800 | fSecondarySet = True; |
---|
801 | } |
---|
802 | } |
---|
803 | } |
---|
804 | } |
---|
805 | else if ((*pch == 'L') || (*pch == 'l')) |
---|
806 | { |
---|
807 | if (StringsAreEqual (pch, ICON_PLACE_LEFT_STR, len)) |
---|
808 | { |
---|
809 | if (!fPrimarySet) |
---|
810 | { |
---|
811 | cval |= ICON_PLACE_LEFT_PRIMARY; |
---|
812 | fPrimarySet = True; |
---|
813 | } |
---|
814 | else if (!fSecondarySet) |
---|
815 | { |
---|
816 | if (!(cval & |
---|
817 | (ICON_PLACE_LEFT_PRIMARY | ICON_PLACE_RIGHT_PRIMARY))) |
---|
818 | { |
---|
819 | cval |= ICON_PLACE_LEFT_SECONDARY; |
---|
820 | fSecondarySet = True; |
---|
821 | } |
---|
822 | } |
---|
823 | } |
---|
824 | } |
---|
825 | |
---|
826 | else if ((*pch == 'R') || (*pch == 'r')) |
---|
827 | { |
---|
828 | if (StringsAreEqual (pch, ICON_PLACE_RIGHT_STR, len)) |
---|
829 | { |
---|
830 | if (!fPrimarySet) |
---|
831 | { |
---|
832 | cval |= ICON_PLACE_RIGHT_PRIMARY; |
---|
833 | fPrimarySet = True; |
---|
834 | } |
---|
835 | else if (!fSecondarySet) |
---|
836 | { |
---|
837 | if (!(cval & |
---|
838 | (ICON_PLACE_RIGHT_PRIMARY | ICON_PLACE_LEFT_PRIMARY))) |
---|
839 | { |
---|
840 | cval |= ICON_PLACE_RIGHT_SECONDARY; |
---|
841 | fSecondarySet = True; |
---|
842 | } |
---|
843 | } |
---|
844 | } |
---|
845 | } |
---|
846 | |
---|
847 | else if ((*pch == 'T') || (*pch == 't')) |
---|
848 | { |
---|
849 | if (StringsAreEqual (pch, ICON_PLACE_TOP_STR, len)) |
---|
850 | { |
---|
851 | if (!fPrimarySet) |
---|
852 | { |
---|
853 | cval |= ICON_PLACE_TOP_PRIMARY; |
---|
854 | fPrimarySet = True; |
---|
855 | } |
---|
856 | else if (!fSecondarySet) |
---|
857 | { |
---|
858 | if (!(cval & |
---|
859 | (ICON_PLACE_TOP_PRIMARY | ICON_PLACE_BOTTOM_PRIMARY))) |
---|
860 | { |
---|
861 | cval |= ICON_PLACE_TOP_SECONDARY; |
---|
862 | fSecondarySet = True; |
---|
863 | } |
---|
864 | } |
---|
865 | } |
---|
866 | |
---|
867 | else if (StringsAreEqual (pch, ICON_PLACE_TIGHT_STR, len)) |
---|
868 | { |
---|
869 | cval |= ICON_PLACE_TIGHT; |
---|
870 | } |
---|
871 | } |
---|
872 | |
---|
873 | pch = pchNext; |
---|
874 | } |
---|
875 | |
---|
876 | if (!fPrimarySet) |
---|
877 | { |
---|
878 | cval = ICON_PLACE_LEFT_PRIMARY; |
---|
879 | } |
---|
880 | if (!fSecondarySet) |
---|
881 | { |
---|
882 | if (cval & (ICON_PLACE_LEFT_PRIMARY | ICON_PLACE_RIGHT_PRIMARY)) |
---|
883 | { |
---|
884 | cval |= ICON_PLACE_BOTTOM_SECONDARY; |
---|
885 | } |
---|
886 | else |
---|
887 | { |
---|
888 | cval |= ICON_PLACE_LEFT_SECONDARY; |
---|
889 | } |
---|
890 | } |
---|
891 | |
---|
892 | |
---|
893 | (*toVal).size = sizeof (long); |
---|
894 | (*toVal).addr = (caddr_t) &cval; |
---|
895 | |
---|
896 | } /* END OF FUNCTION WmCvtStringToIPlace */ |
---|
897 | |
---|
898 | |
---|
899 | |
---|
900 | /*************************************<->************************************* |
---|
901 | * |
---|
902 | * WmCvtStringToKFocus (args, numArgs, fromVal, toVal) |
---|
903 | * |
---|
904 | * |
---|
905 | * Description: |
---|
906 | * ----------- |
---|
907 | * This function converts a string to a keyboard focus policy description. |
---|
908 | * |
---|
909 | * |
---|
910 | * Inputs: |
---|
911 | * ------ |
---|
912 | * args = NULL (don't care) |
---|
913 | * |
---|
914 | * numArgs = 0 (don't care) |
---|
915 | * |
---|
916 | * fromVal = resource value to convert |
---|
917 | * |
---|
918 | * |
---|
919 | * Outputs: |
---|
920 | * ------- |
---|
921 | * toVal = descriptor to use to return converted value |
---|
922 | * |
---|
923 | *************************************<->***********************************/ |
---|
924 | |
---|
925 | #ifdef _NO_PROTO |
---|
926 | void WmCvtStringToKFocus (args, numArgs, fromVal, toVal) |
---|
927 | |
---|
928 | XrmValue *args; |
---|
929 | Cardinal numArgs; |
---|
930 | XrmValue *fromVal; |
---|
931 | XrmValue *toVal; |
---|
932 | #else /* _NO_PROTO */ |
---|
933 | void WmCvtStringToKFocus (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
934 | #endif /* _NO_PROTO */ |
---|
935 | { |
---|
936 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
937 | unsigned char *pchNext; |
---|
938 | int len; |
---|
939 | static int cval; |
---|
940 | Boolean fHit = False; |
---|
941 | |
---|
942 | /* |
---|
943 | * Keyboard focus policies: |
---|
944 | */ |
---|
945 | |
---|
946 | #define KEYBOARD_FOCUS_EXPLICIT_STR (unsigned char *)"explicit" |
---|
947 | #define KEYBOARD_FOCUS_POINTER_STR (unsigned char *)"pointer" |
---|
948 | |
---|
949 | |
---|
950 | /* |
---|
951 | * Convert the keyboard focus policy resource value: |
---|
952 | */ |
---|
953 | |
---|
954 | if (*pch && NextToken (pch, &len, &pchNext)) |
---|
955 | { |
---|
956 | if ((*pch == 'E') || (*pch == 'e')) |
---|
957 | { |
---|
958 | if (StringsAreEqual (pch, KEYBOARD_FOCUS_EXPLICIT_STR, len)) |
---|
959 | { |
---|
960 | cval = KEYBOARD_FOCUS_EXPLICIT; |
---|
961 | fHit = True; |
---|
962 | } |
---|
963 | } |
---|
964 | |
---|
965 | else if ((*pch == 'P') || (*pch == 'p')) |
---|
966 | { |
---|
967 | if (StringsAreEqual (pch, KEYBOARD_FOCUS_POINTER_STR, len)) |
---|
968 | { |
---|
969 | cval = KEYBOARD_FOCUS_POINTER; |
---|
970 | fHit = True; |
---|
971 | } |
---|
972 | } |
---|
973 | } |
---|
974 | |
---|
975 | if (!fHit) |
---|
976 | { |
---|
977 | cval = KEYBOARD_FOCUS_EXPLICIT; |
---|
978 | } |
---|
979 | |
---|
980 | |
---|
981 | (*toVal).size = sizeof (int); |
---|
982 | (*toVal).addr = (caddr_t)&cval; |
---|
983 | |
---|
984 | |
---|
985 | } /* END OF FUNCTION WmCvtStringToKFocus */ |
---|
986 | |
---|
987 | |
---|
988 | |
---|
989 | /*************************************<->************************************* |
---|
990 | * |
---|
991 | * WmCvtStringToSize (args, numArgs, fromVal, toVal) |
---|
992 | * |
---|
993 | * |
---|
994 | * Description: |
---|
995 | * ----------- |
---|
996 | * This function converts a string to a size description (<width>x<height>). |
---|
997 | * |
---|
998 | * |
---|
999 | * Inputs: |
---|
1000 | * ------ |
---|
1001 | * args = NULL (don't care) |
---|
1002 | * |
---|
1003 | * numArgs = 0 (don't care) |
---|
1004 | * |
---|
1005 | * fromVal = resource value to convert |
---|
1006 | * |
---|
1007 | * |
---|
1008 | * Outputs: |
---|
1009 | * ------- |
---|
1010 | * toVal = descriptor to use to return converted value |
---|
1011 | * |
---|
1012 | *************************************<->***********************************/ |
---|
1013 | |
---|
1014 | #ifdef _NO_PROTO |
---|
1015 | void WmCvtStringToSize (args, numArgs, fromVal, toVal) |
---|
1016 | |
---|
1017 | XrmValue *args; |
---|
1018 | Cardinal numArgs; |
---|
1019 | XrmValue *fromVal; |
---|
1020 | XrmValue *toVal; |
---|
1021 | #else /* _NO_PROTO */ |
---|
1022 | void WmCvtStringToSize (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
1023 | #endif /* _NO_PROTO */ |
---|
1024 | { |
---|
1025 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
1026 | unsigned char *pchNext; |
---|
1027 | static WHSize cval; |
---|
1028 | int len; |
---|
1029 | |
---|
1030 | /* |
---|
1031 | * Convenience values for WmSize: |
---|
1032 | */ |
---|
1033 | |
---|
1034 | #define VERTICAL_STR (unsigned char *)"vertical" |
---|
1035 | #define HORIZONTAL_STR (unsigned char *)"horizontal" |
---|
1036 | |
---|
1037 | /* |
---|
1038 | * Convert the size resource value. The syntax is "<width>[xX]<height>" |
---|
1039 | * OR it is the string 'vertical' or 'horizontal'. It's kinda neat that |
---|
1040 | * BIGSIZE is a legal Dimension so that we get vertical and horizontal |
---|
1041 | * for free. |
---|
1042 | */ |
---|
1043 | |
---|
1044 | cval.width = 0; |
---|
1045 | cval.height = 0; |
---|
1046 | |
---|
1047 | if (*pch) |
---|
1048 | { |
---|
1049 | cval.width = (int) DecStrToL (pch, &pchNext); |
---|
1050 | if (!((cval.width == 0) && (pchNext == pch))) |
---|
1051 | { |
---|
1052 | /* |
---|
1053 | * Width was converted. |
---|
1054 | * Check for a delimiter (must be 'x' or 'X'): |
---|
1055 | */ |
---|
1056 | |
---|
1057 | pch = pchNext; |
---|
1058 | if (*pch && ((*pch == 'x') || (*pch == 'X'))) |
---|
1059 | { |
---|
1060 | /* |
---|
1061 | * Delimiter found now get the height: |
---|
1062 | */ |
---|
1063 | |
---|
1064 | pch++; |
---|
1065 | cval.height = (int) DecStrToL (pch, &pchNext); |
---|
1066 | } |
---|
1067 | } |
---|
1068 | else |
---|
1069 | { |
---|
1070 | if (*pch && NextToken (pch, &len, &pchNext)) |
---|
1071 | { |
---|
1072 | if ((*pch == 'V') || (*pch == 'v')) |
---|
1073 | { |
---|
1074 | if (StringsAreEqual (pch, VERTICAL_STR, len)) |
---|
1075 | { |
---|
1076 | cval.height = BIGSIZE; |
---|
1077 | } |
---|
1078 | } |
---|
1079 | else if ((*pch == 'H') || (*pch == 'h')) |
---|
1080 | { |
---|
1081 | if (StringsAreEqual (pch, HORIZONTAL_STR, len)) |
---|
1082 | { |
---|
1083 | cval.width = BIGSIZE; |
---|
1084 | } |
---|
1085 | } |
---|
1086 | } |
---|
1087 | } |
---|
1088 | } |
---|
1089 | |
---|
1090 | /* !!! check for the maximum maximum sizes !!! */ |
---|
1091 | |
---|
1092 | (*toVal).size = sizeof (WHSize); |
---|
1093 | (*toVal).addr = (caddr_t)&cval; |
---|
1094 | |
---|
1095 | |
---|
1096 | } /* END OF FUNCTION WmCvtStringToSize */ |
---|
1097 | |
---|
1098 | |
---|
1099 | /*************************************<->************************************* |
---|
1100 | * |
---|
1101 | * WmCvtStringToShowFeedback (args, numArgs, fromVal, toVal) |
---|
1102 | * |
---|
1103 | * |
---|
1104 | * Description: |
---|
1105 | * ----------- |
---|
1106 | * This function converts a string to a value for the showFeedback flag set. |
---|
1107 | * |
---|
1108 | * |
---|
1109 | * Inputs: |
---|
1110 | * ------ |
---|
1111 | * args = NULL (don't care) |
---|
1112 | * |
---|
1113 | * numArgs = 0 (don't care) |
---|
1114 | * |
---|
1115 | * fromVal = resource value to convert |
---|
1116 | * |
---|
1117 | * |
---|
1118 | * Outputs: |
---|
1119 | * ------- |
---|
1120 | * toVal = descriptor to use to return converted value |
---|
1121 | * |
---|
1122 | *************************************<->***********************************/ |
---|
1123 | |
---|
1124 | #ifdef _NO_PROTO |
---|
1125 | void WmCvtStringToShowFeedback (args, numArgs, fromVal, toVal) |
---|
1126 | |
---|
1127 | XrmValue *args; |
---|
1128 | Cardinal numArgs; |
---|
1129 | XrmValue *fromVal; |
---|
1130 | XrmValue *toVal; |
---|
1131 | #else /* _NO_PROTO */ |
---|
1132 | void WmCvtStringToShowFeedback (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
1133 | #endif /* _NO_PROTO */ |
---|
1134 | { |
---|
1135 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
1136 | unsigned char *pchNext; |
---|
1137 | int len; |
---|
1138 | static long cval; |
---|
1139 | Boolean fHit = False; |
---|
1140 | Boolean fAddNext = True; |
---|
1141 | |
---|
1142 | /* |
---|
1143 | * Names of feedback options |
---|
1144 | */ |
---|
1145 | |
---|
1146 | #define SHOW_FB_ALL_STR (unsigned char *)"all" |
---|
1147 | #define SHOW_FB_BEHAVIOR_STR (unsigned char *)"behavior" |
---|
1148 | #define SHOW_FB_KILL_STR (unsigned char *)"kill" |
---|
1149 | #define SHOW_FB_MOVE_STR (unsigned char *)"move" |
---|
1150 | #define SHOW_FB_NONE_STR (unsigned char *)"none" |
---|
1151 | #define SHOW_FB_PLACEMENT_STR (unsigned char *)"placement" |
---|
1152 | #define SHOW_FB_QUIT_STR (unsigned char *)"quit" |
---|
1153 | #define SHOW_FB_RESIZE_STR (unsigned char *)"resize" |
---|
1154 | #define SHOW_FB_RESTART_STR (unsigned char *)"restart" |
---|
1155 | |
---|
1156 | /* |
---|
1157 | * Check first token. If '-' we subtract from all functions. |
---|
1158 | * Otherwise, we start with no functions and add things in. |
---|
1159 | */ |
---|
1160 | |
---|
1161 | if (*pch && |
---|
1162 | (NextToken (pch, &len, &pchNext)) && |
---|
1163 | (*pch == '-')) |
---|
1164 | { |
---|
1165 | cval = WM_SHOW_FB_DEFAULT; |
---|
1166 | fHit = True; |
---|
1167 | } |
---|
1168 | else |
---|
1169 | { |
---|
1170 | cval = WM_SHOW_FB_NONE; |
---|
1171 | } |
---|
1172 | |
---|
1173 | |
---|
1174 | /* |
---|
1175 | * Convert the feedback option resource value: |
---|
1176 | */ |
---|
1177 | |
---|
1178 | |
---|
1179 | while (*pch && NextToken (pch, &len, &pchNext)) |
---|
1180 | { |
---|
1181 | /* |
---|
1182 | * Strip off "sign" if prepended to another token, and process |
---|
1183 | * that token the next time through. |
---|
1184 | */ |
---|
1185 | |
---|
1186 | if (*pch == '+') |
---|
1187 | { |
---|
1188 | if (len != 1) |
---|
1189 | { |
---|
1190 | pchNext = pch + 1; |
---|
1191 | } |
---|
1192 | fAddNext = TRUE; |
---|
1193 | } |
---|
1194 | |
---|
1195 | else if (*pch == '-') |
---|
1196 | { |
---|
1197 | if (len != 1) |
---|
1198 | { |
---|
1199 | pchNext = pch + 1; |
---|
1200 | } |
---|
1201 | fAddNext = FALSE; |
---|
1202 | } |
---|
1203 | |
---|
1204 | if ((*pch == 'A') || (*pch == 'a')) |
---|
1205 | { |
---|
1206 | if (StringsAreEqual (pch, SHOW_FB_ALL_STR, len)) |
---|
1207 | { |
---|
1208 | cval = fAddNext ? (cval | WM_SHOW_FB_ALL) : |
---|
1209 | (cval & ~WM_SHOW_FB_ALL); |
---|
1210 | fHit = True; |
---|
1211 | } |
---|
1212 | } |
---|
1213 | |
---|
1214 | else if ((*pch == 'B') || (*pch == 'b')) |
---|
1215 | { |
---|
1216 | if (StringsAreEqual (pch, SHOW_FB_BEHAVIOR_STR, len)) |
---|
1217 | { |
---|
1218 | cval = fAddNext ? (cval | WM_SHOW_FB_BEHAVIOR) : |
---|
1219 | (cval & ~WM_SHOW_FB_BEHAVIOR); |
---|
1220 | fHit = True; |
---|
1221 | } |
---|
1222 | } |
---|
1223 | |
---|
1224 | else if ((*pch == 'K') || (*pch == 'k')) |
---|
1225 | { |
---|
1226 | if (StringsAreEqual (pch, SHOW_FB_KILL_STR, len)) |
---|
1227 | { |
---|
1228 | cval = fAddNext ? (cval | WM_SHOW_FB_KILL) : |
---|
1229 | (cval & ~WM_SHOW_FB_KILL); |
---|
1230 | fHit = True; |
---|
1231 | } |
---|
1232 | } |
---|
1233 | |
---|
1234 | else if ((*pch == 'M') || (*pch == 'm')) |
---|
1235 | { |
---|
1236 | if (StringsAreEqual (pch, SHOW_FB_MOVE_STR, len)) |
---|
1237 | { |
---|
1238 | cval = fAddNext ? (cval | WM_SHOW_FB_MOVE) : |
---|
1239 | (cval & ~WM_SHOW_FB_MOVE); |
---|
1240 | fHit = True; |
---|
1241 | } |
---|
1242 | } |
---|
1243 | |
---|
1244 | else if ((*pch == 'N') || (*pch == 'n')) |
---|
1245 | { |
---|
1246 | if (StringsAreEqual (pch, SHOW_FB_NONE_STR, len)) |
---|
1247 | { |
---|
1248 | /* don't bother adding or subtracting nothing */ |
---|
1249 | fHit = True; |
---|
1250 | } |
---|
1251 | } |
---|
1252 | |
---|
1253 | else if ((*pch == 'P') || (*pch == 'p')) |
---|
1254 | { |
---|
1255 | if (StringsAreEqual (pch, SHOW_FB_PLACEMENT_STR, len)) |
---|
1256 | { |
---|
1257 | cval = fAddNext ? (cval | WM_SHOW_FB_PLACEMENT) : |
---|
1258 | (cval & ~WM_SHOW_FB_PLACEMENT); |
---|
1259 | fHit = True; |
---|
1260 | } |
---|
1261 | } |
---|
1262 | |
---|
1263 | else if ((*pch == 'Q') || (*pch == 'q')) |
---|
1264 | { |
---|
1265 | if (StringsAreEqual (pch, SHOW_FB_QUIT_STR, len)) |
---|
1266 | { |
---|
1267 | cval = fAddNext ? (cval | WM_SHOW_FB_QUIT) : |
---|
1268 | (cval & ~WM_SHOW_FB_QUIT); |
---|
1269 | fHit = True; |
---|
1270 | } |
---|
1271 | } |
---|
1272 | |
---|
1273 | else if ((*pch == 'R') || (*pch == 'r')) |
---|
1274 | { |
---|
1275 | if (StringsAreEqual (pch, SHOW_FB_RESIZE_STR, len)) |
---|
1276 | { |
---|
1277 | cval = fAddNext ? (cval | WM_SHOW_FB_RESIZE) : |
---|
1278 | (cval & ~WM_SHOW_FB_RESIZE); |
---|
1279 | fHit = True; |
---|
1280 | } |
---|
1281 | else if (StringsAreEqual (pch, SHOW_FB_RESTART_STR, len)) |
---|
1282 | { |
---|
1283 | cval = fAddNext ? (cval | WM_SHOW_FB_RESTART) : |
---|
1284 | (cval & ~WM_SHOW_FB_RESTART); |
---|
1285 | fHit = True; |
---|
1286 | } |
---|
1287 | } |
---|
1288 | pch = pchNext; |
---|
1289 | } |
---|
1290 | |
---|
1291 | |
---|
1292 | |
---|
1293 | /* |
---|
1294 | * If we didn't match anything then set to default. |
---|
1295 | */ |
---|
1296 | if (!fHit) |
---|
1297 | { |
---|
1298 | cval = WM_SHOW_FB_DEFAULT; |
---|
1299 | } |
---|
1300 | |
---|
1301 | |
---|
1302 | (*toVal).size = sizeof (long); |
---|
1303 | (*toVal).addr = (caddr_t) &cval; |
---|
1304 | |
---|
1305 | } /* END OF FUNCTION WmCvtStringToShowFeedback */ |
---|
1306 | |
---|
1307 | |
---|
1308 | |
---|
1309 | /*************************************<->************************************* |
---|
1310 | * |
---|
1311 | * WmCvtStringToUsePPosition (args, numArgs, fromVal, toVal) |
---|
1312 | * |
---|
1313 | * |
---|
1314 | * Description: |
---|
1315 | * ----------- |
---|
1316 | * This function converts a string to a keyboard focus policy description. |
---|
1317 | * |
---|
1318 | * |
---|
1319 | * Inputs: |
---|
1320 | * ------ |
---|
1321 | * args = NULL (don't care) |
---|
1322 | * |
---|
1323 | * numArgs = 0 (don't care) |
---|
1324 | * |
---|
1325 | * fromVal = resource value to convert |
---|
1326 | * |
---|
1327 | * |
---|
1328 | * Outputs: |
---|
1329 | * ------- |
---|
1330 | * toVal = descriptor to use to return converted value |
---|
1331 | * |
---|
1332 | *************************************<->***********************************/ |
---|
1333 | |
---|
1334 | #ifdef _NO_PROTO |
---|
1335 | void WmCvtStringToUsePPosition (args, numArgs, fromVal, toVal) |
---|
1336 | |
---|
1337 | XrmValue *args; |
---|
1338 | Cardinal numArgs; |
---|
1339 | XrmValue *fromVal; |
---|
1340 | XrmValue *toVal; |
---|
1341 | #else /* _NO_PROTO */ |
---|
1342 | void WmCvtStringToUsePPosition (XrmValue *args, Cardinal numArgs, XrmValue *fromVal, XrmValue *toVal) |
---|
1343 | #endif /* _NO_PROTO */ |
---|
1344 | { |
---|
1345 | unsigned char *pch = (unsigned char *) (fromVal->addr); |
---|
1346 | unsigned char *pchNext; |
---|
1347 | int len; |
---|
1348 | static int cval; |
---|
1349 | Boolean fHit = False; |
---|
1350 | |
---|
1351 | |
---|
1352 | #define USE_PPOSITION_NONZERO_STR (unsigned char *)"nonzero" |
---|
1353 | #define USE_PPOSITION_ON_STR (unsigned char *)"on" |
---|
1354 | #define USE_PPOSITION_OFF_STR (unsigned char *)"off" |
---|
1355 | |
---|
1356 | /* |
---|
1357 | * Convert the use PPosition resource value: |
---|
1358 | */ |
---|
1359 | |
---|
1360 | if (*pch && NextToken (pch, &len, &pchNext)) |
---|
1361 | { |
---|
1362 | if ((*pch == 'N') || (*pch == 'n')) |
---|
1363 | { |
---|
1364 | if (StringsAreEqual (pch, USE_PPOSITION_NONZERO_STR, len)) |
---|
1365 | { |
---|
1366 | cval = USE_PPOSITION_NONZERO; |
---|
1367 | fHit = True; |
---|
1368 | } |
---|
1369 | } |
---|
1370 | else if (StringsAreEqual (pch, USE_PPOSITION_OFF_STR, len)) |
---|
1371 | { |
---|
1372 | cval = USE_PPOSITION_OFF; |
---|
1373 | fHit = True; |
---|
1374 | } |
---|
1375 | else if (StringsAreEqual (pch, USE_PPOSITION_ON_STR, len)) |
---|
1376 | { |
---|
1377 | cval = USE_PPOSITION_ON; |
---|
1378 | fHit = True; |
---|
1379 | } |
---|
1380 | } |
---|
1381 | |
---|
1382 | if (!fHit) |
---|
1383 | { |
---|
1384 | cval = USE_PPOSITION_NONZERO; |
---|
1385 | } |
---|
1386 | |
---|
1387 | (*toVal).size = sizeof (int); |
---|
1388 | (*toVal).addr = (caddr_t)&cval; |
---|
1389 | |
---|
1390 | |
---|
1391 | } /* END OF FUNCTION WmCvtStringToUsePPosition */ |
---|
1392 | |
---|
1393 | |
---|
1394 | |
---|
1395 | /*************************************<->************************************* |
---|
1396 | * |
---|
1397 | * NextToken (pchIn, pLen, ppchNext) |
---|
1398 | * |
---|
1399 | * |
---|
1400 | * Description: |
---|
1401 | * ----------- |
---|
1402 | * XXDescription ... |
---|
1403 | * |
---|
1404 | * |
---|
1405 | * Inputs: |
---|
1406 | * ------ |
---|
1407 | * pchIn = pointer to start of next token |
---|
1408 | * |
---|
1409 | * |
---|
1410 | * Outputs: |
---|
1411 | * ------- |
---|
1412 | * pLen = pointer to integer containing number of characters in next token |
---|
1413 | * ppchNext = address of pointer to following token |
---|
1414 | * |
---|
1415 | * Return = next token or NULL |
---|
1416 | * |
---|
1417 | * |
---|
1418 | * Comments: |
---|
1419 | * -------- |
---|
1420 | * None. |
---|
1421 | * |
---|
1422 | *************************************<->***********************************/ |
---|
1423 | |
---|
1424 | unsigned char *NextToken (pchIn, pLen, ppchNext) |
---|
1425 | |
---|
1426 | unsigned char *pchIn; |
---|
1427 | int *pLen; |
---|
1428 | unsigned char **ppchNext; |
---|
1429 | { |
---|
1430 | unsigned char *pchR = pchIn; |
---|
1431 | register int i; |
---|
1432 | |
---|
1433 | #ifndef NO_MULTIBYTE |
---|
1434 | register int chlen; |
---|
1435 | |
---|
1436 | for (i = 0; |
---|
1437 | ((chlen = mblen((char *)pchIn, MB_CUR_MAX)) > 0) && (pchIn[0] != '\0'); |
---|
1438 | i++) |
---|
1439 | /* find end of word: requires singlebyte whitespace terminator */ |
---|
1440 | { |
---|
1441 | if ((chlen == 1) && isspace (*pchIn)) |
---|
1442 | { |
---|
1443 | break; |
---|
1444 | } |
---|
1445 | pchIn += chlen; |
---|
1446 | } |
---|
1447 | |
---|
1448 | #else |
---|
1449 | for (i = 0; *pchIn && !isspace (*pchIn); i++, pchIn++) |
---|
1450 | /* find end of word */ |
---|
1451 | { |
---|
1452 | } |
---|
1453 | #endif |
---|
1454 | |
---|
1455 | /* skip to next word */ |
---|
1456 | ScanWhitespace (&pchIn); |
---|
1457 | |
---|
1458 | *ppchNext = pchIn; |
---|
1459 | *pLen = i; |
---|
1460 | if (i) |
---|
1461 | { |
---|
1462 | return(pchR); |
---|
1463 | } |
---|
1464 | else |
---|
1465 | { |
---|
1466 | return(NULL); |
---|
1467 | } |
---|
1468 | |
---|
1469 | } /* END OF FUNCTION NextToken */ |
---|
1470 | |
---|
1471 | |
---|
1472 | |
---|
1473 | /*************************************<->************************************* |
---|
1474 | * |
---|
1475 | * StringsAreEqual (pch1, pch2, len) |
---|
1476 | * |
---|
1477 | * |
---|
1478 | * Description: |
---|
1479 | * ----------- |
---|
1480 | * XXDescription ... |
---|
1481 | * |
---|
1482 | * |
---|
1483 | * Inputs: |
---|
1484 | * ------ |
---|
1485 | * pch1 = |
---|
1486 | * pch2 = |
---|
1487 | * len = |
---|
1488 | * |
---|
1489 | * |
---|
1490 | * Outputs: |
---|
1491 | * ------- |
---|
1492 | * Return = (Boolean) True iff strings match (case insensitive) |
---|
1493 | * |
---|
1494 | * |
---|
1495 | * Comments: |
---|
1496 | * -------- |
---|
1497 | * None. |
---|
1498 | * |
---|
1499 | *************************************<->***********************************/ |
---|
1500 | |
---|
1501 | #ifdef _NO_PROTO |
---|
1502 | Boolean StringsAreEqual (pch1, pch2, len) |
---|
1503 | |
---|
1504 | unsigned char *pch1; |
---|
1505 | unsigned char *pch2; |
---|
1506 | int len; /* character count */ |
---|
1507 | #else /* _NO_PROTO */ |
---|
1508 | Boolean StringsAreEqual (unsigned char *pch1, unsigned char *pch2, int len) |
---|
1509 | #endif /* _NO_PROTO */ |
---|
1510 | { |
---|
1511 | #ifndef NO_MULTIBYTE |
---|
1512 | int chlen1; |
---|
1513 | int chlen2; |
---|
1514 | wchar_t wch1; |
---|
1515 | wchar_t wch2; |
---|
1516 | |
---|
1517 | while (len && |
---|
1518 | ((chlen1 = mbtowc (&wch1, (char *) pch1, MB_CUR_MAX)) > 0) && |
---|
1519 | ((chlen2 = mbtowc (&wch2, (char *) pch2, MB_CUR_MAX)) == chlen1) ) |
---|
1520 | { |
---|
1521 | if (chlen1 == 1) |
---|
1522 | /* singlebyte characters -- make case insensitive */ |
---|
1523 | { |
---|
1524 | if ((isupper (*pch1) ? tolower(*pch1) : *pch1) != |
---|
1525 | (isupper (*pch2) ? tolower(*pch2) : *pch2)) |
---|
1526 | { |
---|
1527 | break; |
---|
1528 | } |
---|
1529 | } |
---|
1530 | else |
---|
1531 | /* multibyte characters */ |
---|
1532 | { |
---|
1533 | if (wch1 != wch2) |
---|
1534 | { |
---|
1535 | break; |
---|
1536 | } |
---|
1537 | } |
---|
1538 | pch1 += chlen1; |
---|
1539 | pch2 += chlen2; |
---|
1540 | len--; |
---|
1541 | } |
---|
1542 | |
---|
1543 | #else |
---|
1544 | while (len && *pch1 && *pch2 && |
---|
1545 | ((isupper (*pch1) ? tolower(*pch1++) : *pch1++) == |
---|
1546 | (isupper (*pch2) ? tolower(*pch2++) : *pch2++))) |
---|
1547 | { |
---|
1548 | len--; |
---|
1549 | } |
---|
1550 | #endif |
---|
1551 | |
---|
1552 | return (len == 0); |
---|
1553 | |
---|
1554 | } /* END OF StringsAreEqual */ |
---|
1555 | |
---|
1556 | |
---|
1557 | |
---|
1558 | /*************************************<->************************************* |
---|
1559 | * |
---|
1560 | * long |
---|
1561 | * DecStrToL (str, ptr) |
---|
1562 | * |
---|
1563 | * |
---|
1564 | * Description: |
---|
1565 | * ----------- |
---|
1566 | * Converts a decimal string to a long. |
---|
1567 | * |
---|
1568 | * |
---|
1569 | * Inputs: |
---|
1570 | * ------ |
---|
1571 | * str = character string |
---|
1572 | * |
---|
1573 | * |
---|
1574 | * Outputs: |
---|
1575 | * ------- |
---|
1576 | * *ptr = pointer to character terminating str or str |
---|
1577 | * Return = long value |
---|
1578 | * |
---|
1579 | * |
---|
1580 | * Comments: |
---|
1581 | * -------- |
---|
1582 | * Leading whitespace is ignored. |
---|
1583 | * Returns long value with *ptr pointing at character terminating the decimal |
---|
1584 | * string. |
---|
1585 | * Returns 0 with *ptr == str if no integer can be formed. |
---|
1586 | * |
---|
1587 | *************************************<->***********************************/ |
---|
1588 | |
---|
1589 | long DecStrToL (str, ptr) |
---|
1590 | |
---|
1591 | unsigned char *str; |
---|
1592 | unsigned char **ptr; |
---|
1593 | { |
---|
1594 | long val = 0; |
---|
1595 | |
---|
1596 | *ptr = str; |
---|
1597 | #ifndef NO_MULTIBYTE |
---|
1598 | while ((mblen ((char *)str, MB_CUR_MAX) == 1) && isspace (*str)) |
---|
1599 | #else |
---|
1600 | while (isspace (*str)) |
---|
1601 | #endif |
---|
1602 | /* Ignore leading whitespace */ |
---|
1603 | { |
---|
1604 | str++; |
---|
1605 | } |
---|
1606 | |
---|
1607 | /* If we can start, we will reset *ptr */ |
---|
1608 | #ifndef NO_MULTIBYTE |
---|
1609 | if ((mblen ((char *)str, MB_CUR_MAX) == 1) && isdigit (*str)) |
---|
1610 | { |
---|
1611 | while ((mblen ((char *)str, MB_CUR_MAX) == 1) && isdigit (*str)) |
---|
1612 | #else |
---|
1613 | if (isdigit (*str)) |
---|
1614 | { |
---|
1615 | while (isdigit (*str)) |
---|
1616 | #endif |
---|
1617 | { |
---|
1618 | val = val * 10 + (*str - '0'); |
---|
1619 | str++; |
---|
1620 | } |
---|
1621 | |
---|
1622 | *ptr = str; |
---|
1623 | } |
---|
1624 | |
---|
1625 | return (val); |
---|
1626 | |
---|
1627 | } /* END OF FUNCTION DecStrToL */ |
---|
1628 | |
---|