Merge branch 'master' of https://git.code.sf.net/p/cdesktopenv/code
[oweals/cde.git] / cde / programs / dtmail / dtmail / DmxPrintOptions.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: DmxPrintOptions.C /main/8 1997/04/30 09:44:12 mgreess $ */
24
25 /*
26  *+SNOTICE
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *      
30  *      The information in this document is subject to special
31  *      restrictions in a confidential disclosure agreement between
32  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
33  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
34  *      Sun's specific written approval.  This document and all copies
35  *      and derivative works thereof must be returned or destroyed at
36  *      Sun's request.
37  *
38  *      Copyright 1994 Sun Microsystems, Inc.  All rights reserved.
39  *
40  *+ENOTICE
41  */
42 /*
43  *                   Common Desktop Environment
44  *
45  *   (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
46  *   (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
47  *   (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
48  *   (c) Copyright 1993, 1994, 1995 Novell, Inc.
49  *   (c) Copyright 1995 Digital Equipment Corp.
50  *   (c) Copyright 1995 Fujitsu Limited
51  *   (c) Copyright 1995 Hitachi, Ltd.
52  *                                                                   
53  *
54  *                     RESTRICTED RIGHTS LEGEND                              
55  *
56  *Use, duplication, or disclosure by the U.S. Government is subject to
57  *restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
58  *Technical Data and Computer Software clause in DFARS 252.227-7013.  Rights
59  *for non-DOD U.S. Government Departments and Agencies are as set forth in
60  *FAR 52.227-19(c)(1,2).
61
62  *Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
63  *International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A. 
64  *Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
65  *Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
66  *Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
67  *Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
68  *Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
69  */
70
71
72 #include <stdio.h>
73 #include <X11/Intrinsic.h>
74 #include <Xm/Xm.h>
75 #include <Xm/DialogS.h>
76 #include <Xm/Form.h>
77 #include <Xm/ToggleB.h>
78 #include <Dt/PrintOptionsP.h>
79
80 #include "Dmx.h"
81 #include "DmxPrintOptions.h"
82 #include "DtMail.hh"
83 #include "DtMailError.hh"
84 #include "dtmailopts.h"
85 #include "IndexedOptionMenuUiItem.hh"
86 #include "MailMsg.h"
87 #include "RoamApp.h"
88 #include "TextFieldUiItem.hh"
89
90 #define DMX_ARRAY_SIZE(ary)     (sizeof((ary))/sizeof((ary)[0]))
91
92 static DmxpoPropKey hdrftr_keys[] =
93 {
94     { (int) DTPRINT_OPTION_HEADER_LEFT,
95       DMX_PROPKEY_HEADER_LEFT,
96       DMX_PROPVAL_SUBJECT_HEADER
97     },
98     { (int) DTPRINT_OPTION_HEADER_RIGHT,
99       DMX_PROPKEY_HEADER_RIGHT,
100       DMX_PROPVAL_EMPTY
101     },
102     { (int) DTPRINT_OPTION_FOOTER_LEFT,
103       DMX_PROPKEY_FOOTER_LEFT,
104       DMX_PROPVAL_USER_NAME
105     },
106     { (int) DTPRINT_OPTION_FOOTER_RIGHT,
107       DMX_PROPKEY_FOOTER_RIGHT,
108       DMX_PROPVAL_PAGE_NUMBER
109     }
110 };
111
112 static DmxpoPropKey margin_keys[] =
113 {
114     { (int) DTPRINT_OPTION_MARGIN_TOP,
115       DMX_PROPKEY_MARGIN_TOP,
116       DMX_PROPVAL_DFLT_MARGIN
117     },
118     { (int) DTPRINT_OPTION_MARGIN_LEFT,
119       DMX_PROPKEY_MARGIN_LEFT,
120       DMX_PROPVAL_DFLT_MARGIN
121     },
122     { (int) DTPRINT_OPTION_MARGIN_BOTTOM,
123       DMX_PROPKEY_MARGIN_BOTTOM,
124       DMX_PROPVAL_DFLT_MARGIN
125     },
126     { (int) DTPRINT_OPTION_MARGIN_RIGHT,
127       DMX_PROPKEY_MARGIN_RIGHT,
128       DMX_PROPVAL_DFLT_MARGIN
129     }
130 };
131
132 static DmxpoPropValue hdrftr_values[] =
133 {
134     { (int) DMX_NONE_STRING,
135       DMX_PROPVAL_EMPTY,
136       22, 1, "Empty"
137     },
138     { (int) DMX_CC_HEADER_STRING,
139       DMX_PROPVAL_CC_HEADER,
140       22, 2, "CC Header"
141     },
142     { (int) DMX_DATE_HEADER_STRING,
143       DMX_PROPVAL_DATE_HEADER,
144       22, 3, "Date Header"
145     },
146     { (int) DMX_FROM_HEADER_STRING,
147       DMX_PROPVAL_FROM_HEADER,
148       22, 4, "From Header"
149     },
150     { (int) DMX_SUBJECT_HEADER_STRING,
151       DMX_PROPVAL_SUBJECT_HEADER,
152       22, 5, "Subject Header"
153     },
154     { (int) DMX_TO_HEADER_STRING,
155       DMX_PROPVAL_TO_HEADER,
156       22, 6, "To Header"
157     },
158     { (int) DMX_PAGE_NUMBER_STRING,
159       DMX_PROPVAL_PAGE_NUMBER,
160       22, 7, "Page Number"
161     },
162     { (int) DMX_USER_NAME_STRING,
163       DMX_PROPVAL_USER_NAME,
164       22, 8, "User Name"
165     }
166 };
167                                     
168 static DmxpoPropValue prthdr_values[] =
169 {
170     { (int) DMX_PRINT_HEADERS_NONE,
171       DMX_PROPVAL_NONE,
172       23, 1, "None" },
173     { (int) DMX_PRINT_HEADERS_STANDARD,
174       DMX_PROPVAL_STANDARD,
175       23, 2, "Standard" },
176     { (int) DMX_PRINT_HEADERS_ABBREV,
177       DMX_PROPVAL_ABBREVIATED,
178       23, 3, "Abbreviated" },
179     { (int) DMX_PRINT_HEADERS_ALL,
180       DMX_PROPVAL_ALL,
181       23, 4, "All" }
182 };
183                                     
184 static DmxpoPropValue msgsep_values[] =
185 {
186     { (int) DMX_SEPARATOR_NEW_LINE,
187       DMX_PROPVAL_NEW_LINE,
188       24, 1, "New Line" },
189     { (int) DMX_SEPARATOR_BLANK_LINE,
190       DMX_PROPVAL_BLANK_LINE,
191       24, 2, "Blank Line" },
192     { (int) DMX_SEPARATOR_CHARACTER_LINE,
193       DMX_PROPVAL_CHARACTER_LINE,
194       24, 3, "Character Line" },
195     { (int) DMX_SEPARATOR_PAGE_BREAK,
196       DMX_PROPVAL_PAGE_BREAK,
197       24, 4, "New Page" }
198 };
199                                     
200
201
202 DmxPrintOptions::DmxPrintOptions (
203                                 Widget parent
204                                 ) : UIComponent( "PrintOptions" )
205 {
206     IndexedOptionMenu   *iom = (IndexedOptionMenu *) NULL;
207     PropUiItem          *pui = (PropUiItem  *) NULL;
208     Widget              *menu_buttons, w;
209     int                 nitems;
210     char                **strings;
211     void                **data;
212     XmString            xms;
213     int                 i, j, nhdrftrs;
214
215     _iom_array = new DtVirtArray<IndexedOptionMenu *>(10);
216     _propui_array = new DtVirtArray<PropUiItem *>(10);
217     _propui_array_iterator = 0;
218     _parent = parent;
219
220     //
221     //  Create form to hold the printing options
222     //
223     _form = XtVaCreateWidget(
224                                 "PrintingOptionsPane",
225                                 xmFormWidgetClass,
226                                 _parent,
227                                 XmNbottomAttachment, XmATTACH_FORM,
228                                 XmNrightAttachment, XmATTACH_FORM,
229                                 XmNleftAttachment, XmATTACH_FORM,
230                                 XmNtopAttachment, XmATTACH_FORM,
231                                 XmNresizePolicy, XmRESIZE_ANY,
232                                 NULL
233                                 );
234     if (_form == (Widget) NULL) return;
235     _w = _form;
236     installDestroyHandler();
237
238     //
239     //  Create GUI for the Header/Footer options
240     //
241     nitems = DMX_ARRAY_SIZE(hdrftr_values);;
242     strings = (char **) XtMalloc( nitems * sizeof(char*) );
243     data = (void **) XtMalloc( nitems * sizeof(void*) );
244     for (i=0; i<nitems; i++)
245     {
246         data[i] = (void*) hdrftr_values[i].prop_string;
247         strings[i] = GETMSG(
248                         DT_catd, 
249                         hdrftr_values[i].set_id, 
250                         hdrftr_values[i].msg_id,
251                         hdrftr_values[i].dflt_string
252                         );
253     }
254
255     _hdrftr_frame = _DtPrintCreateHdrFtrFrame( _form, nitems, strings, data);
256     XtVaSetValues(
257                 _hdrftr_frame,
258                 XmNtopAttachment, XmATTACH_FORM,
259                 XmNleftAttachment, XmATTACH_FORM,
260                 NULL
261                 );
262     XtManageChild(_hdrftr_frame);
263
264     //
265     //  Create PropUiItem's for the Header/Footer options
266     //
267     menu_buttons = NULL;
268     _DtPrintHdrFtrFrameMenuWidgets( _hdrftr_frame, NULL, NULL, &menu_buttons);
269     for (j=0, nhdrftrs=DMX_ARRAY_SIZE(hdrftr_keys); j<nhdrftrs; j++)
270     {
271         w = _DtPrintHdrFtrFrameEnumToWidget(
272                                 _hdrftr_frame,
273                                 (_DtPrintHdrFtrEnum) hdrftr_keys[j].which
274                                 );
275         iom =
276           new IndexedOptionMenu(w, nitems, (char**)strings, data, menu_buttons);
277         iom->manage();
278         _iom_array->append(iom);
279
280         pui = (PropUiItem *) new IndexedOptionMenuUiItem(
281                                                         iom,
282                                                         _FROM_MAILRC,
283                                                         hdrftr_keys[j].key
284                                                         );
285         _propui_array->append(pui);
286     }
287     XtFree((char*) menu_buttons);
288     XtFree((char*) data);
289     XtFree((char*) strings);
290
291
292     //
293     //  Create GUI for the Margin options
294     //
295     _margin_frame = _DtPrintCreateMarginFrame(_form);
296     XtVaSetValues(
297                 _margin_frame,
298                 XmNtopAttachment, XmATTACH_WIDGET,
299                 XmNtopWidget, _hdrftr_frame,
300                 XmNleftAttachment, XmATTACH_FORM,
301                 NULL
302                 );
303     XtManageChild(_margin_frame);
304
305     //
306     //  Create PropUiItem's for the Margin options
307     //
308     nitems = DMX_ARRAY_SIZE(margin_keys);
309     for (j=0; j<nitems; j++)
310     {
311         w = _DtPrintMarginFrameEnumToWidget(
312                                 _margin_frame,
313                                 (_DtPrintMarginEnum) margin_keys[j].which
314                                 );
315         pui = (PropUiItem *) new TextFieldUiItem(
316                                         w,
317                                         _FROM_MAILRC,
318                                         margin_keys[j].key,
319                                         DmxPrintOptions::isValidMarginSpec,
320                                         (void*) margin_keys[j].which);
321         _propui_array->append(pui);
322     }
323
324
325     //
326     //  Create GUI for the Printed Headers option
327     //
328     nitems = DMX_ARRAY_SIZE(prthdr_values);;
329     strings = (char **) XtMalloc( nitems * sizeof(char*) );
330     data = (void **) XtMalloc( nitems * sizeof(void*) );
331     for (i=0; i<nitems; i++)
332     {
333         data[i] = (void*) prthdr_values[i].prop_string;
334         strings[i] = GETMSG(
335                         DT_catd, 
336                         prthdr_values[i].set_id, 
337                         prthdr_values[i].msg_id,
338                         prthdr_values[i].dflt_string
339                         );
340     }
341
342     iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
343     xms = XmStringCreateLocalized(
344                 GETMSG(DT_catd, 25, 1, "Printed Message Headers:  ")
345                 );
346     XtVaSetValues(
347                 iom->baseWidget(),
348                 XmNlabelString, xms,
349                 XmNtopAttachment, XmATTACH_WIDGET,
350                 XmNtopWidget, _margin_frame,
351                 XmNrightAttachment, XmATTACH_FORM,
352                 XmNleftAttachment, XmATTACH_FORM,
353                 NULL
354                 );
355     iom->manage();
356     _prthdr_iom = iom;
357     _iom_array->append(iom);
358
359     XmStringFree(xms);
360     XtFree((char*) strings);
361     XtFree((char*) data);
362
363     //
364     //  Create PropUiItem for the Printed Headers option
365     //
366     pui = (PropUiItem *) new IndexedOptionMenuUiItem(
367                                                 iom,
368                                                 _FROM_MAILRC,
369                                                 DMX_PROPKEY_PRINT_HEADERS
370                                                 );
371     _propui_array->append(pui);
372
373
374     //
375     //  Create GUI for the Message Separator option
376     //
377     nitems = DMX_ARRAY_SIZE(msgsep_values);;
378     strings = (char **) XtMalloc( nitems * sizeof(char*) );
379     data = (void **) XtMalloc( nitems * sizeof(void*) );
380     for (i=0; i<nitems; i++)
381     {
382         data[i] = (void*) msgsep_values[i].prop_string;
383         strings[i] = GETMSG(
384                         DT_catd, 
385                         msgsep_values[i].set_id, 
386                         msgsep_values[i].msg_id,
387                         msgsep_values[i].dflt_string
388                         );
389     }
390
391     iom = new IndexedOptionMenu(_form, nitems, (char**) strings, data);
392     xms = XmStringCreateLocalized(
393                 GETMSG( DT_catd, 25, 2, "Separate Multiple Messages With:  ")
394                 );
395     XtVaSetValues(
396                 iom->baseWidget(),
397                 XmNlabelString, xms,
398                 XmNtopAttachment, XmATTACH_WIDGET,
399                 XmNtopWidget, _prthdr_iom->baseWidget(),
400                 XmNrightAttachment, XmATTACH_FORM,
401                 XmNleftAttachment, XmATTACH_FORM,
402                 XmNbottomAttachment, XmATTACH_FORM,
403                 NULL
404                 );
405     iom->manage();
406     _iom_array->append(iom);
407     _msgsep_iom = iom;
408
409     XmStringFree(xms);
410     XtFree((char*) strings);
411     XtFree((char*) data);
412
413     //
414     //  Create PropUiItem for the Message Separator option
415     //
416     pui = (PropUiItem *) new IndexedOptionMenuUiItem(
417                                                 iom,
418                                                 _FROM_MAILRC,
419                                                 DMX_PROPKEY_MESSAGE_SEPARATOR);
420     _propui_array->append(pui);
421
422     //XtRealizeWidget(_w);
423     //XtManageChild(_w);
424 }
425
426
427 DmxPrintOptions::~DmxPrintOptions (void)
428 {
429     int i;
430     PropUiItem          *pui;;
431     IndexedOptionMenu   *iom;
432
433     if (_propui_array)
434       for (i=0; i<_propui_array->length(); i++)
435       {
436           pui = (*_propui_array)[i];
437           delete pui;
438       }
439
440     if (_iom_array)
441       for (i=0; i<_iom_array->length(); i++)
442       {
443           iom = (*_iom_array)[i];
444           delete iom;
445       }
446
447     if (_w)
448       XtDestroyWidget(_w);
449 }
450
451 PropUiItem *
452 DmxPrintOptions::getFirstProp(void)
453 {
454     _propui_array_iterator = 0;
455     return getNextProp();
456 }
457
458 PropUiItem *
459 DmxPrintOptions::getNextProp(void)
460 {
461     PropUiItem  *pui = (PropUiItem  *) NULL;
462
463     if (_propui_array_iterator < _propui_array->length())
464     {
465         pui = (*_propui_array)[_propui_array_iterator];
466         _propui_array_iterator++;
467     }
468     return pui;
469 }
470
471 int
472 DmxPrintOptions::getNumProps(void)
473 {
474     return _propui_array->length();
475 }
476
477 const char *
478 DmxPrintOptions::getSeparatorString(void)
479 {
480     DtMail::Session     *d_session = NULL;
481     DtMail::MailRc      *m_rc = NULL;
482     DtMailEnv           error;
483     const char          *string = NULL;
484     char                *dflt = "-";
485
486     d_session = theRoamApp.session()->session();
487     m_rc = d_session->mailRc(error);
488
489     m_rc->getValue(error, DMX_PROPKEY_SEPARATOR_STRING, &string);
490     if (string == NULL || error.isSet())
491       return strdup(dflt);
492
493     return string;
494 }
495
496 DmxStringTypeEnum
497 DmxPrintOptions::getHdrFtrSpec(_DtPrintHdrFtrEnum which)
498 {
499     DtMail::Session     *d_session = NULL;
500     DtMail::MailRc      *m_rc = NULL;
501     DtMailEnv           error;
502     DmxpoPropKey        *key;
503     const char          *string = NULL;
504     DmxpoPropValue      *value = NULL;
505     DmxStringTypeEnum   rtn = DMX_NONE_STRING;
506
507     d_session = theRoamApp.session()->session();
508     m_rc = d_session->mailRc(error);
509
510     key = DmxPrintOptions::enumToPropKey(
511                                 which,
512                                 DMX_ARRAY_SIZE(hdrftr_keys),
513                                 hdrftr_keys
514                                 );
515
516     if (key != NULL)
517     {
518         m_rc->getValue(error, key->key , &string);
519         if (string == NULL || error.isSet())
520           string = strdup(key->dflt_prop_string);
521     }
522     else
523       return rtn;
524
525     value = stringToPropValue(
526                         string,
527                         DMX_ARRAY_SIZE(hdrftr_values),
528                         hdrftr_values);
529     if (value != NULL)
530       rtn = (DmxStringTypeEnum) value->which;
531
532     if (NULL != string)
533       free((void*) string);
534
535     return rtn;
536 }
537
538 const char *
539 DmxPrintOptions::getMarginSpec(_DtPrintMarginEnum which)
540 {
541     DtMail::Session     *d_session = NULL;
542     DtMail::MailRc      *m_rc = NULL;
543     DtMailEnv           error;
544     DmxpoPropKey        *key;
545     const char          *string = NULL;
546
547     d_session = theRoamApp.session()->session();
548     m_rc = d_session->mailRc(error);
549
550     key = DmxPrintOptions::enumToPropKey(
551                                 which,
552                                 DMX_ARRAY_SIZE(margin_keys),
553                                 margin_keys
554                                 );
555
556     if (key == NULL)
557       return DMX_PROPVAL_DFLT_MARGIN;
558
559     m_rc->getValue(error, key->key , &string);
560     if (string == NULL || error.isSet())
561       string = strdup(key->dflt_prop_string);
562
563     return string;
564 }
565
566 DmxMsgSeparatorEnum
567 DmxPrintOptions::getMessageSeparator(void)
568 {
569     DtMail::Session     *d_session = NULL;
570     DtMail::MailRc      *m_rc = NULL;
571     DtMailEnv           error;
572     const char          *string = NULL;
573     DmxpoPropValue      *value = NULL;
574     DmxMsgSeparatorEnum rtn = DMX_SEPARATOR_PAGE_BREAK;
575
576     d_session = theRoamApp.session()->session();
577     m_rc = d_session->mailRc(error);
578
579     m_rc->getValue(error, DMX_PROPKEY_MESSAGE_SEPARATOR , &string);
580     if (string == NULL || error.isSet())
581       return rtn;
582
583     value = stringToPropValue(
584                         string,
585                         DMX_ARRAY_SIZE(msgsep_values),
586                         msgsep_values);
587     if (value != NULL)
588       rtn = (DmxMsgSeparatorEnum) value->which;
589
590     if (NULL != string)
591       free((void*) string);
592
593     return rtn;
594 }
595
596 DmxPrintHeadersEnum
597 DmxPrintOptions::getPrintedHeaders(void)
598 {
599     DtMail::Session     *d_session = NULL;
600     DtMail::MailRc      *m_rc = NULL;
601     DtMailEnv           error;
602     const char          *string = NULL;
603     DmxpoPropValue      *value = NULL;
604     DmxPrintHeadersEnum rtn = DMX_PRINT_HEADERS_STANDARD;
605
606     d_session = theRoamApp.session()->session();
607     m_rc = d_session->mailRc(error);
608
609     m_rc->getValue(error, DMX_PROPKEY_PRINT_HEADERS , &string);
610     if (string == NULL || error.isSet())
611       return rtn;
612
613     value = stringToPropValue(
614                         string,
615                         DMX_ARRAY_SIZE(prthdr_values),
616                         prthdr_values);
617     if (value != NULL)
618       rtn = (DmxPrintHeadersEnum) value->which;
619
620     if (NULL != string)
621       free((void*) string);
622
623     return rtn;
624 }
625
626 DmxpoPropKey *
627 DmxPrintOptions::enumToPropKey(int which, int nkeys, DmxpoPropKey *keys)
628 {
629     for (int i=0; i<nkeys; i++)
630       if (keys[i].which == which)
631         return &(keys[i]);
632     
633     return NULL;
634 }
635
636 PropUiItem *
637 DmxPrintOptions::propKeyToPropItem(char *key)
638 {
639     for (int i=0; i<_propui_array->length(); i++)
640     {
641         PropUiItem      *pui;
642         char            *puikey;
643
644         pui = (*_propui_array)[i];
645         puikey = pui->getKey();
646         if (strcmp(puikey, key) == 0)
647           return pui;
648     }
649     
650     return NULL;
651 }
652
653 DmxpoPropValue *
654 DmxPrintOptions::stringToPropValue(
655                                 const char *string,
656                                 int nvalues,
657                                 DmxpoPropValue *values
658                                 )
659 {
660     for (int i=0; i<nvalues; i++)
661       if (strcmp(values[i].prop_string, string) == 0)
662         return &(values[i]);
663     
664     return NULL;
665 }
666
667 char *
668 DmxPrintOptions::isValidMarginSpec(PropUiItem* pui, void* data)
669 {
670     char        *i18nMsg;
671     char        *errMsg = NULL;
672     char        *marginSpec = NULL;
673     XtEnum      parseError;
674     Widget      text;
675 #if defined(linux) || defined(CSRG_BASED)
676     _DtPrintMarginEnum which = *((_DtPrintMarginEnum *) data);
677 #else
678     _DtPrintMarginEnum which = (_DtPrintMarginEnum) data;
679 #endif
680
681     text = pui->getWidget();
682     if (text)
683       marginSpec = _DtPrintGetMarginSpec(text);
684
685     parseError = FALSE;
686     if (marginSpec == NULL || strcmp("", marginSpec) == 0)
687       parseError = TRUE;
688     else 
689       (void) XmConvertStringToUnits(
690                                 XtScreenOfObject(text),
691                                 marginSpec,
692                                 XmVERTICAL,
693                                 XmPIXELS,
694                                 &parseError);
695  
696     if (! parseError) return NULL;
697  
698     switch (which)
699     {
700       case DTPRINT_OPTION_MARGIN_TOP:
701         i18nMsg =
702           GETMSG(DT_catd, 26, 1, "Top Margin specifier is invalid:  ");
703         break;
704       case DTPRINT_OPTION_MARGIN_RIGHT:
705         i18nMsg =
706           GETMSG(DT_catd, 26, 2, "Right Margin specifier is invalid:  ");
707         break;
708       case DTPRINT_OPTION_MARGIN_BOTTOM:
709         i18nMsg =
710           GETMSG(DT_catd, 26, 3, "Bottom Margin specifier is invalid:  ");
711         break;
712       case DTPRINT_OPTION_MARGIN_LEFT:
713         i18nMsg =
714           GETMSG(DT_catd, 26, 4, "Left Margin specifier is invalid:  ");
715         break;
716     }
717     errMsg = (char*) XtMalloc(strlen(i18nMsg) + strlen(marginSpec) + 1);
718     sprintf(errMsg, "%s%s", i18nMsg, marginSpec);
719     
720     return errMsg;
721 }