123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $XConsortium: PrintOptions.c /main/4 1996/04/29 17:12:37 rswiston $ */
- /*
- *+SNOTICE
- *
- * $:$
- *
- * RESTRICTED CONFIDENTIAL INFORMATION:
- *
- * The information in this document is subject to special
- * restrictions in a confidential disclosure agreement between
- * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
- * document outside HP, IBM, Sun, USL, SCO, or Univel without
- * Sun's specific written approval. This document and all copies
- * and derivative works thereof must be returned or destroyed at
- * Sun's request.
- *
- * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
- *
- *+ENOTICE
- */
- /*
- * Common Desktop Environment
- *
- * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
- * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
- * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
- * (c) Copyright 1993, 1994, 1995 Novell, Inc.
- * (c) Copyright 1995 Digital Equipment Corp.
- * (c) Copyright 1995 Fujitsu Limited
- * (c) Copyright 1995 Hitachi, Ltd.
- *
- *
- * RESTRICTED RIGHTS LEGEND
- *
- * Use, duplication, or disclosure by the U.S. Government is subject to
- * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
- * Technical Data and Computer Software clause in DFARS 252.227-7013. Rights
- * for non-DOD U.S. Government Departments and Agencies are as set forth in
- * FAR 52.227-19(c)(1,2).
- *
- * Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
- * International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A.
- * Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
- * Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
- * Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
- * Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
- * Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
- */
-
- #include <Xm/XmAll.h>
- #include "Dt/Print.h"
- #include "PrintMsgsP.h"
- #include "PrintOptionsP.h"
- /******************************************************************************
- *
- * Static functions
- *
- ******************************************************************************/
- static void
- _DtPrintDestroyHdrFtrFrameCB(
- Widget frame,
- XtPointer client_data,
- XtPointer call_data
- );
- static void
- _DtPrintDestroyMarginFrameCB(
- Widget frame,
- XtPointer client_data,
- XtPointer call_data
- );
- /******************************************************************************
- *
- * _DtPrint Header/Footer API
- *
- ******************************************************************************/
- typedef struct dtpo_header_footer_spec
- {
- Widget button;
- void *data;
- char *string;
- } DtpoHdrFtrSpec;
- typedef struct dtpo_header_footer_frame
- {
- Widget frame,
- label,
- form,
- menu,
- top_left,
- top_right,
- bottom_left,
- bottom_right;
-
- int nspecs;
- DtpoHdrFtrSpec *specs;
- } DtpoHdrFtrFrame;
- static void
- _DtPrintDestroyHdrFtrFrameCB(
- Widget frame,
- XtPointer client_data,
- XtPointer call_data
- )
- {
- DtpoHdrFtrFrame *info = (DtpoHdrFtrFrame *) client_data;
- if (info == NULL) return;
- if (info->specs != NULL)
- XtFree((char*) info->specs);
- XtFree((char*) info);
- }
- /*
- * Function: _DtPrintCreateHdrFtrFrame
- *
- * Creates a frame for specifying the contents of page headers and footers.
- * The frame contains four option menus, one for each _DtPrintHdrFtrEnum.
- * The pulldown menus for the option menu are constructed from the .string
- * field in the array of _DtPrintHdrFtrSpec in "specs".
- *
- * _DtPrintCreateHdrFtrFrame copies the pointer to the array of
- * _DtPrintHdrFtrSpec. IT DOES NOT COPY THE ELEMENTS OF THE ARRAY.
- *
- * parent - specifies the parent of the frame.
- * nspecs - specifies the number of entries in the specs array.
- * specs - array of header/footer specifiers. The .string
- * field is used to construct labels in the GUI.
- * The .data field is returned in calls to
- * _DtPrintGetHdrFtrSpec.
- *
- * Returns the widget id for the frame.
- */
- Widget
- _DtPrintCreateHdrFtrFrame(
- Widget parent,
- int nspecs,
- char **spec_strings,
- void **spec_data
- )
- {
- DtpoHdrFtrFrame *info;
- Arg args[16];
- int n;
- int i;
- XmString xms;
- info = (DtpoHdrFtrFrame *) XtMalloc( sizeof(DtpoHdrFtrFrame) );
- info->nspecs = nspecs;
- info->specs = (DtpoHdrFtrSpec *) XtMalloc(nspecs*sizeof(DtpoHdrFtrSpec));
- for (i=0; i<nspecs; i++)
- {
- info->specs[i].string = spec_strings[i];
- if (spec_data != (void*) NULL)
- info->specs[i].data = spec_data[i];
- else
- info->specs[i].data = (void*) NULL;
- info->specs[i].button = (Widget) NULL;
- }
- /*
- * Create the frame and attach add a destroyCallback to clean up
- * memory allocated for this object.
- */
- n = 0;
- XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
- XtSetArg(args[n], XmNuserData, info); n++;
- info->frame = XmCreateFrame(parent, "HdrFtrFrame", args, n);
- XtAddCallback(
- info->frame,
- XmNdestroyCallback,
- _DtPrintDestroyHdrFtrFrameCB,
- (XtPointer) info
- );
- /*
- * Create a label child for the frame
- */
- xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_LABEL);
- n = 0;
- XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
- XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- info->label = XmCreateLabel(info->frame, "HdrFtrLabel", args, n);
- XtManageChild(info->label);
- XmStringFree(xms);
- /*
- * Create a form work area child which will be populated by the
- * OptionMenu's.
- */
- n = 0;
- XtSetArg(args[n], XmNallowOverlap, False); n++;
- XtSetArg(args[n], XmNfractionBase, 2); n++;
- info->form = XmCreateForm(info->frame, "HdrFtrForm", args, n);
- /*
- * Create the pulldown menu for the option menus.
- * Store the button index in the userData resource of each button.
- */
- info->menu = XmCreatePulldownMenu(parent, "HdrFtrMenu", NULL, 0);
- for (i=0; i<info->nspecs; i++)
- {
- static char button_label[32];
- sprintf(button_label, "Button%d", i);
- xms = XmStringCreateLocalized(info->specs[i].string);
- n = 0;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNuserData, i); n++;
- info->specs[i].button =
- XmCreatePushButtonGadget(info->menu, button_label, args, n);
- XmStringFree(xms);
- XtManageChild(info->specs[i].button);
- }
- /*
- * Create the option menus using the menu created above.
- */
- xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_TOP_LEFT_LABEL);
- n=0;
- XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNuserData, info); n++;
- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
- XtSetArg(args[n], XmNrightPosition, 1); n++;
- XtSetArg(args[n], XmNrightOffset, 5); n++;
- info->top_left = XmCreateOptionMenu(
- info->form,
- "PageHeaderLeftOM",
- args, n
- );
- XmStringFree(xms);
- XtManageChild(info->top_left);
- xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_TOP_RIGHT_LABEL);
- n=0;
- XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNuserData, info); n++;
- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->top_left); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- info->top_right = XmCreateOptionMenu(
- info->form,
- "PageHeaderRightOM",
- args, n
- );
- XmStringFree(xms);
- XtManageChild(info->top_right);
- xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_BOTTOM_LEFT_LABEL);
- n=0;
- XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNuserData, info); n++;
- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->top_left); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->top_left); n++;
- XtSetArg(args[n], XmNrightOffset, 0); n++;
- info->bottom_left = XmCreateOptionMenu(
- info->form,
- "PageFooterLeftOM",
- args, n
- );
- XmStringFree(xms);
- XtManageChild(info->bottom_left);
- xms = XmStringCreateLocalized(DTPO_HEADERFOOTER_FRAME_BOTTOM_RIGHT_LABEL);
- n=0;
- XtSetArg(args[n], XmNsubMenuId, info->menu); n++;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNuserData, info); n++;
- XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->bottom_left); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->top_right); n++;
- XtSetArg(args[n], XmNrightOffset, 0); n++;
- info->bottom_right = XmCreateOptionMenu(
- info->form,
- "PageFooterRightOM",
- args, n
- );
- XmStringFree(xms);
- XtManageChild(info->bottom_right);
- XtManageChild(info->form);
- return info->frame;
- }
- /*
- * Function: _DtPrintHdrFtrFrameEnumToWidget
- *
- * Returns the widget id of the option menu corresponding the specified
- * header or footer.
- *
- * frame - specifies the HdrFtr frame
- * which - specifies the particular header or footer in "frame".
- *
- * Returns the widget id of the option menu for "which"
- */
- Widget
- _DtPrintHdrFtrFrameEnumToWidget(
- Widget frame,
- _DtPrintHdrFtrEnum which
- )
- {
- DtpoHdrFtrFrame *info;
- Widget widget = NULL;
- XtVaGetValues(frame, XmNuserData, &info, NULL);
- if (info == NULL)
- return widget;
- switch (which)
- {
- case DTPRINT_OPTION_HEADER_LEFT:
- widget = info->top_left; break;
- case DTPRINT_OPTION_HEADER_RIGHT:
- widget = info->top_right; break;
- case DTPRINT_OPTION_FOOTER_LEFT:
- widget = info->bottom_left; break;
- case DTPRINT_OPTION_FOOTER_RIGHT:
- widget = info->bottom_right; break;
- default:
- widget = NULL;
- }
- return widget;
- }
- /*
- * Function: _DtPrintHdrFtrFrameMenuWidgets
- *
- * widget -specifies the option menu
- *
- * Returns the widgets which make up the pulldown menu.
- */
- void
- _DtPrintHdrFtrFrameMenuWidgets(
- Widget frame,
- Widget *menu,
- int *nmenu_buttons,
- Widget **menu_buttons
- )
- {
- int i;
- DtpoHdrFtrFrame *info;
- if (frame == NULL) return;
- XtVaGetValues(frame, XmNuserData, &info, NULL);
- if (info == NULL) return;
- if (menu != NULL)
- *menu = info->menu;
- if (nmenu_buttons != NULL)
- *nmenu_buttons = info->nspecs;
- if (menu_buttons != NULL)
- {
- if (*menu_buttons == NULL)
- *menu_buttons = (Widget *) XtMalloc( info->nspecs * sizeof(Widget) );
-
- for (i=0; i<info->nspecs; i++)
- (*menu_buttons)[i] = info->specs[i].button;
- }
- }
- /*
- * Function: _DtPrintGetHdrFtrIndex
- *
- * option - specifies the HdrFtr option menu
- *
- * Returns the index of the active menu option of the specified
- * option menu.
- */
- int
- _DtPrintGetHdrFtrIndex(
- Widget option
- )
- {
- int index = -1;
- Widget selected;
- if (! option) return index;
- XtVaGetValues(option, XmNmenuHistory, &selected, NULL);
- XtVaGetValues(selected, XmNuserData, &index, NULL);
- return index;
- }
- /*
- * Function: _DtPrintGetHdrFtrData
- *
- * option - specifies the HdrFtr option menu
- *
- * Returns the data associated with the active menu option of the specified
- * option menu.
- */
- void *
- _DtPrintGetHdrFtrData(
- Widget option
- )
- {
- int index = 0;
- DtpoHdrFtrFrame *info = NULL;
- if (! option) return (void*) NULL;
- XtVaGetValues(option, XmNuserData, &info, NULL);
- if (info == NULL) return 0;
- index = _DtPrintGetHdrFtrIndex(option);
- return info->specs[index].data;
- }
- /*
- * Function: _DtPrintGetHdrFtrString
- *
- * option - specifies the HdrFtr option menu
- *
- * Returns the string associated with the active menu option of the specified
- * option menu.
- */
- char *
- _DtPrintGetHdrFtrString(
- Widget option
- )
- {
- int index = 0;
- DtpoHdrFtrFrame *info = NULL;
- if (! option) return (void*) NULL;
- XtVaGetValues(option, XmNuserData, &info, NULL);
- if (info == NULL) return 0;
- index = _DtPrintGetHdrFtrIndex(option);
- return info->specs[index].string;
- }
- /*
- * Function: _DtPrintSetHdrFtrByData
- *
- * Displays the specified menu item as the currently active option.
- *
- * option - specifies the HdrFtr option menu
- * data - data associated with the option to be displayed.
- */
- void
- _DtPrintSetHdrFtrByData(
- Widget option,
- void *data
- )
- {
- int i;
- DtpoHdrFtrFrame *info;
- if (option == NULL) return;
- XtVaGetValues(option, XmNuserData, &info, NULL);
- if (info == NULL) return;
- for (i=0; i<info->nspecs; i++)
- if (info->specs[i].data == data)
- {
- XtVaSetValues(option, XmNmenuHistory, info->specs[i].button, NULL);
- return;
- }
- }
- /*
- * Function: _DtPrintSetHdrFtrByIndex
- *
- * Displays the specified menu item as the currently active option.
- *
- * option - specifies the HdrFtr option menu
- * index - specifies the option to be displayed.
- */
- void
- _DtPrintSetHdrFtrByIndex(
- Widget option,
- int index
- )
- {
- DtpoHdrFtrFrame *info;
- if (option == NULL) return;
- XtVaGetValues(option, XmNuserData, &info, NULL);
- if (info == NULL) return;
- XtVaSetValues(option, XmNmenuHistory, info->specs[index].button, NULL);
- }
- /*
- * Function: _DtPrintSetHdrFtrByString
- *
- * Displays the specified menu item as the currently active option.
- *
- * option - specifies the HdrFtr option menu
- * string - string associated with the option to be displayed.
- */
- void
- _DtPrintSetHdrFtrByString(
- Widget option,
- char *string
- )
- {
- int i;
- DtpoHdrFtrFrame *info;
- if (option == NULL) return;
- XtVaGetValues(option, XmNuserData, &info, NULL);
- if (info == NULL) return;
- for (i=0; i<info->nspecs; i++)
- if (strcmp(info->specs[i].string,string) == 0)
- {
- XtVaSetValues(option, XmNmenuHistory, info->specs[i].button, NULL);
- return;
- }
- }
- /******************************************************************************
- *
- * _DtPrint Margin API
- *
- ******************************************************************************/
- typedef struct dtpo_margin_frame
- {
- Widget frame,
- label,
- form,
- top,
- right,
- bottom,
- left,
- top_label,
- right_label,
- bottom_label,
- left_label;
- } DtpoMarginFrame;
- static void
- _DtPrintDestroyMarginFrameCB(
- Widget frame,
- XtPointer client_data,
- XtPointer call_data
- )
- {
- DtpoHdrFtrFrame *info = (DtpoHdrFtrFrame *) client_data;
- if (info == NULL) return;
- XtFree((char*) info);
- }
- /*
- * Function: _DtPrintCreateMarginFrame
- *
- * Creates a frame for specifying margins. The frame contains four text
- * fields, one for each _DtPrintMarginEnum.
- *
- * parent - specifies the parent of the frame.
- *
- * Returns the widget id of the frame.
- */
- Widget
- _DtPrintCreateMarginFrame(
- Widget parent
- )
- {
- DtpoMarginFrame
- *info;
- Arg args[16];
- int n;
- XmString xms;
- info = (DtpoMarginFrame *) XtMalloc( sizeof(DtpoMarginFrame) );
- n = 0;
- XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
- XtSetArg(args[n], XmNuserData, info); n++;
- info->frame = XmCreateFrame(parent, "MarginFrame", args, n);
- XtAddCallback(
- info->frame,
- XmNdestroyCallback,
- _DtPrintDestroyMarginFrameCB,
- (XtPointer) info
- );
- xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_LABEL);
- n = 0;
- XtSetArg(args[n], XmNchildType, XmFRAME_TITLE_CHILD); n++;
- XtSetArg(args[n], XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING); n++;
- XtSetArg(args[n], XmNchildVerticalAlignment, XmALIGNMENT_CENTER); n++;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- info->label = XmCreateLabel(info->frame, "MarginLabel", args, n);
- XtManageChild(info->label);
- XmStringFree(xms);
- n = 0;
- XtSetArg(args[n], XmNallowOverlap, False); n++;
- XtSetArg(args[n], XmNfractionBase, 2); n++;
- info->form = XmCreateForm(info->frame, "MarginForm", args, n);
- n = 0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
- XtSetArg(args[n], XmNrightPosition, 1); n++;
- XtSetArg(args[n], XmNrightOffset, 5); n++;
- info->top = XmCreateTextField(info->form, "MarginTopText", args, n);
- XtManageChild(info->top);
- xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_TOP_MARGIN_LABEL);
- n = 0;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->top); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->top); n++;
- XtSetArg(args[n], XmNrightOffset, 3); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNbottomWidget, info->top); n++;
- XtSetArg(args[n], XmNbottomOffset, 0); n++;
- info->top_label =
- XmCreateLabelGadget(info->form, "MarginTopLabel", args, n);
- XmStringFree(xms);
- XtManageChild(info->top_label);
- n = 0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->top); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
- info->right = XmCreateTextField(info->form, "MarginRightText", args, n);
- XtManageChild(info->right);
- xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_RIGHT_MARGIN_LABEL);
- n = 0;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->right); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->right); n++;
- XtSetArg(args[n], XmNrightOffset, 3); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNbottomWidget, info->right); n++;
- XtSetArg(args[n], XmNbottomOffset, 0); n++;
- info->right_label =
- XmCreateLabelGadget(info->form, "MarginRightLabel", args, n);
- XmStringFree(xms);
- XtManageChild(info->right_label);
- n = 0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->top); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->top); n++;
- XtSetArg(args[n], XmNrightOffset, 0); n++;
- info->bottom = XmCreateTextField(info->form, "MarginBottomText", args, n);
- XtManageChild(info->bottom);
- xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_BOTTOM_MARGIN_LABEL);
- n = 0;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->bottom); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->bottom); n++;
- XtSetArg(args[n], XmNrightOffset, 3); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNbottomWidget, info->bottom); n++;
- XtSetArg(args[n], XmNbottomOffset, 0); n++;
- info->bottom_label =
- XmCreateLabelGadget(info->form, "MarginBottomLabel", args, n);
- XmStringFree(xms);
- XtManageChild(info->bottom_label);
- n = 0;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->bottom); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->right); n++;
- XtSetArg(args[n], XmNrightOffset, 0); n++;
- info->left = XmCreateTextField(info->form, "MarginLeftText", args, n);
- XtManageChild(info->left);
- xms = XmStringCreateLocalized(DTPO_MARGIN_FRAME_LEFT_MARGIN_LABEL);
- n = 0;
- XtSetArg(args[n], XmNlabelString, xms); n++;
- XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNtopWidget, info->left); n++;
- XtSetArg(args[n], XmNtopOffset, 0); n++;
- XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
- XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
- XtSetArg(args[n], XmNrightWidget, info->left); n++;
- XtSetArg(args[n], XmNrightOffset, 3); n++;
- XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
- XtSetArg(args[n], XmNbottomWidget, info->left); n++;
- XtSetArg(args[n], XmNbottomOffset, 0); n++;
- info->left_label =
- XmCreateLabelGadget(info->form, "MarginLeftLabel", args, n);
- XmStringFree(xms);
- XtManageChild(info->left_label);
- XtManageChild(info->form);
- return info->frame;
- }
- /*
- * Function: _DtPrintMarginFrameEnumToWidget
- *
- * frame - specifies the HdrFtr frame
- * which - specifies the particular margin in "frame".
- *
- * Returns the widget id of the textfield for "which"
- */
- Widget
- _DtPrintMarginFrameEnumToWidget(
- Widget frame,
- _DtPrintMarginEnum which
- )
- {
- DtpoMarginFrame *info;
- Widget widget = NULL;
- XtVaGetValues(frame, XmNuserData, &info, NULL);
- if (info == NULL)
- return widget;
- switch (which)
- {
- case DTPRINT_OPTION_MARGIN_TOP:
- widget = info->top; break;
- case DTPRINT_OPTION_MARGIN_RIGHT:
- widget = info->right; break;
- case DTPRINT_OPTION_MARGIN_BOTTOM:
- widget = info->bottom; break;
- case DTPRINT_OPTION_MARGIN_LEFT:
- widget = info->left; break;
- default:
- break;
- }
- return widget;
- }
- /*
- * Function: _DtPrintGetMarginSpec
- *
- * margin - specifies the margin widget.
- *
- * Returns a copy of the contents of the specified margin.
- * The calling function should free this string when done with it.
- */
- char*
- _DtPrintGetMarginSpec(
- Widget margin
- )
- {
- char *spec = NULL;
- if (margin)
- spec = XmTextFieldGetString(margin);
- return spec;
- }
- /*
- * Function: _DtPrintSetMarginSpec
- *
- * margin -specifies the margin widget.
- * spec - specifies the string to be displayed in the GUI.
- *
- */
- void
- _DtPrintSetMarginSpec(
- Widget margin,
- char *spec
- )
- {
- if (margin)
- XmTextFieldSetString(margin, spec);
- }
|