2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: AddFiletype.c /main/8 1999/09/17 15:43:02 mgreess $ */
24 /***************************************************************************/
28 /* Associated Header file: AddFiletype.h */
31 /***************************************************************************/
37 #include <Xm/MwmUtil.h>
38 #include <Xm/DialogS.h>
39 #include <Xm/MenuShell.h>
40 #include <Xm/Separator.h>
42 #include <Xm/ScrolledW.h>
46 #include <Xm/PushBG.h>
56 #include "CreateActionAppShell.h"
57 #include "FileCharacteristics.h"
60 #define CONTEXT_MACRO_ACCESS 1
61 #include "AddFiletype.h"
62 #undef CONTEXT_MACRO_ACCESS
64 /*******************************************************************************
66 *******************************************************************************/
68 enum mode {NONE, NEW, SAVE, QUIT};
72 enum icon_size_range filetype_icon_size = None_Selected;
74 enum icon_size_range filetype_icon_size;
77 /*******************************************************************************
78 The following are callback functions.
79 *******************************************************************************/
82 /******************************************************************************/
84 /* LayoutCB_AddFiletype */
86 /* INPUT: Widget wid - window id */
87 /* XtPointer cdata - client data */
88 /* XtPointer *cbstruct - callback data */
91 /******************************************************************************/
92 void LayoutCB_AddFiletype(Widget wid, XtPointer cdata, XtPointer cbs)
94 printf("In layout callback of AddFiletype\n");
98 /******************************************************************************/
99 /* activateCB_edit_id_characteristics - bring up file characteristics dialog */
100 /* INPUT: Widget filesel - edit button id */
101 /* XtPointer cdata - client data */
102 /* XtPointer *cbstruct - callback data */
104 /******************************************************************************/
105 void activateCB_edit_id_characteristics (Widget filesel, XtPointer cdata,
106 XmFileSelectionBoxCallbackStruct *cbstruct)
110 XtVaGetValues (AddFiletype,
114 /*FileCharacteristics = create_FileCharacteristics();*/
116 XtVaSetValues (FileCharacteristics,
119 clear_FileCharacteristics_dialog_fields();
120 init_FileCharacteristics_dialog_fields(pFtD);
121 UxPopupInterface (FILE_CHARACTERISTICS, no_grab);
125 static void activateCB_AF_OkButton( Widget UxWidget,
126 XtPointer UxClientData,
127 XtPointer UxCallbackArg)
130 FiletypeData **papArray;
133 /**************************************************************************/
134 /* Check if fields are valid. */
135 /**************************************************************************/
136 if (!AddFiletypeCheckFields()) {
138 /***********************************************************************/
139 /* Get FiletypeData structure that was allocated when Add button on */
140 /* the CreateActionAppShell interface was activated. */
141 /***********************************************************************/
142 XtVaGetValues(AddFiletype, XmNuserData, &pFtD, NULL);
144 /***********************************************************************/
145 /* Get all values from gui */
146 /***********************************************************************/
149 /***********************************************************************/
150 /* If in edit mode, then don't do add type things. */
151 /***********************************************************************/
152 if (!(pFtD->fsInternal & CA_FT_EDIT)) {
154 /********************************************************************/
155 /* Update the Filetype listbox with this new filetype */
156 /********************************************************************/
159 /********************************************************************/
160 /* Update FiletypeData array within the ActionData structure */
161 /********************************************************************/
162 UpdateFiletypeDataArray(pFtD);
166 /***********************************************************************/
167 /* Unset previous set values. */
168 /***********************************************************************/
169 pFtD->fsInternal &= (~(CA_FT_APPLY));
170 pFtD->fsInternal &= (~(CA_FT_EDIT));
172 /***********************************************************************/
173 /* Pop down the AddFiletype interface */
174 /***********************************************************************/
175 UxPopdownInterface(AddFiletype);
179 static void activateCB_AF_ApplyButton( Widget UxWidget,
180 XtPointer UxClientData,
181 XtPointer UxCallbackArg)
185 /**************************************************************************/
186 /* Check if fields are valid. */
187 /**************************************************************************/
188 if (!AddFiletypeCheckFields()) {
190 /***********************************************************************/
191 /* Get FiletypeData structure that was allocated when Add button on */
192 /* the CreateActionAppShell interface was activated. */
193 /***********************************************************************/
194 XtVaGetValues(AddFiletype, XmNuserData, &pFtD, NULL);
196 /***********************************************************************/
197 /* Get all values from gui */
198 /***********************************************************************/
201 /***********************************************************************/
202 /* Set the variable that indicates that Apply button was used. */
203 /***********************************************************************/
204 pFtD->fsInternal |= CA_FT_APPLY;
206 /***********************************************************************/
207 /* If in edit mode, then don't do apply type things. */
208 /***********************************************************************/
209 if (!(pFtD->fsInternal & CA_FT_EDIT)) {
211 /********************************************************************/
212 /* Update the Filetype listbox with this new filetype */
213 /********************************************************************/
214 if (XmListItemExists(CA_FiletypesList, XmStringCreateSimple("NONE"))) {
215 XmListDeleteItem(CA_FiletypesList, XmStringCreateSimple("NONE"));
219 /********************************************************************/
220 /* Update FiletypeData array within the ActionData structure */
221 /********************************************************************/
222 UpdateFiletypeDataArray(pFtD);
228 static void activateCB_AF_CancelButton( Widget UxWidget,
229 XtPointer UxClientData,
230 XtPointer UxCallbackArg)
234 UxPopdownInterface(AddFiletype);
235 XtVaGetValues(AddFiletype, XmNuserData, &pFtD, NULL);
236 if (!((pFtD->fsInternal & CA_FT_APPLY) || (pFtD->fsInternal & CA_FT_EDIT))) {
237 free_Filetypedata(pFtD);
239 pFtD->fsInternal &= (~(CA_FT_APPLY));
240 pFtD->fsInternal &= (~(CA_FT_EDIT));
244 /*******************************************************************************
245 The 'build_' function creates all the widgets
246 using the resource values specified in the Property Editor.
247 *******************************************************************************/
249 static Widget _Uxbuild_AddFiletype(void)
253 Widget AF_CharacteristicsWindow;
254 Widget ActionAreaForm;
255 int ntotalbuttons = 4;
257 Widget AF_ScrolledWindow;
259 XtArgVal /* Dimension */ dim1, dim2, dim3;
260 Widget AF_MED_IconForm, AF_TINY_IconForm;
262 char *pre, *suf, *title;
264 XmString emptyString;
268 #define ICON_MIN_HEIGHT 83
269 #define FINDEDIT_SPACING 6
270 #define BORDER_OFFSET 3
272 /* Creation of AddFiletype */
273 _UxParent = UxParent;
274 if ( _UxParent == NULL )
276 _UxParent = UxTopLevel;
279 pre = GETMESSAGE(3, 10, "Create Action");
280 suf = GETMESSAGE(7, 10, "Add Datatype");
281 len = strlen(pre) + strlen(suf) + 4;
282 title = XtMalloc(len);
283 snprintf(title,len - 1, "%s - %s", pre, suf);
285 _UxParent = XtVaCreatePopupShell( "AddFiletype_shell",
286 xmDialogShellWidgetClass, _UxParent,
289 XmNshellUnitType, XmPIXELS,
293 XtAddCallback(_UxParent, XmNpopupCallback, LayoutCB_AddFiletype, NULL);
297 AF_BigForm = XtVaCreateWidget( "AF_BigForm",
300 XmNunitType, XmPIXELS,
301 XmNdialogStyle, XmDIALOG_APPLICATION_MODAL,
302 RES_CONVERT( XmNdialogTitle, title ),
303 XmNautoUnmanage, FALSE,
305 AF_ScrolledWindow = XtVaCreateManagedWidget( "AF_ScrolledWindow",
306 xmScrolledWindowWidgetClass,
308 XmNscrollingPolicy, XmAUTOMATIC,
309 XmNleftAttachment, XmATTACH_FORM,
310 XmNrightAttachment, XmATTACH_FORM,
311 XmNbottomAttachment, XmATTACH_FORM,
312 XmNtopAttachment, XmATTACH_FORM,
314 XtVaSetValues(AF_BigForm, XmNuserData, AF_ScrolledWindow, NULL);
316 AddFiletype = XtVaCreateManagedWidget( "AddFiletype",
321 AddFiletype = XtVaCreateWidget( "AddFiletype",
324 XmNunitType, XmPIXELS,
325 XmNdialogStyle, XmDIALOG_APPLICATION_MODAL,
326 RES_CONVERT( XmNdialogTitle, title ),
327 XmNautoUnmanage, FALSE,
333 XtAddCallback( AddFiletype, XmNhelpCallback,
334 (XtCallbackProc) helpCB_general,
335 (XtPointer) HELP_ADDFILETYPE );
337 /* Creation of AF_FiletypeFamilyNameLabel */
338 AF_FiletypeFamilyNameLabel = XtVaCreateManagedWidget( "AF_FiletypeFamilyNameLabel",
341 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 14, "Name of Datatype Family:")),
342 XmNalignment, XmALIGNMENT_BEGINNING,
344 XmNtopAttachment, XmATTACH_FORM,
346 XmNleftAttachment, XmATTACH_FORM,
348 XmNrightAttachment, XmATTACH_FORM,
351 /* Creation of AF_FileTypeNameTextField */
352 AF_FileTypeNameTextField = XtVaCreateManagedWidget( "AF_FileTypeNameTextField",
353 xmTextFieldWidgetClass,
356 XmNtopWidget, AF_FiletypeFamilyNameLabel,
357 XmNtopAttachment, XmATTACH_WIDGET,
359 XmNleftAttachment, XmATTACH_FORM,
361 XmNrightAttachment, XmATTACH_FORM,
364 ActionAreaForm = XtVaCreateManagedWidget( "ActionAreaForm",
367 XmNnavigationType, XmTAB_GROUP,
369 XmNfractionBase, ((TIGHTNESS * ntotalbuttons) - 1),
371 XmNleftAttachment, XmATTACH_FORM,
373 XmNrightAttachment, XmATTACH_FORM,
375 XmNbottomAttachment, XmATTACH_FORM,
378 /* Creation of AF_OkButton */
379 AF_OkButton = XtVaCreateManagedWidget( "AF_OkButton",
380 xmPushButtonGadgetClass,
382 RES_CONVERT( XmNlabelString, GETMESSAGE(6, 10, "OK")),
383 XmNmultiClick, XmMULTICLICK_DISCARD,
384 XmNleftAttachment, nbutton ?
385 XmATTACH_POSITION : XmATTACH_FORM,
386 XmNleftPosition, TIGHTNESS * nbutton,
387 XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
388 XmATTACH_POSITION : XmATTACH_FORM,
389 XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
392 XtAddCallback( AF_OkButton, XmNactivateCallback,
393 (XtCallbackProc) activateCB_AF_OkButton,
396 /* Creation of AF_ApplyButton */
397 AF_ApplyButton = XtVaCreateManagedWidget( "AF_ApplyButton",
398 xmPushButtonGadgetClass,
400 RES_CONVERT( XmNlabelString, GETMESSAGE(6, 11, "Apply")),
401 XmNleftAttachment, nbutton ?
402 XmATTACH_POSITION : XmATTACH_FORM,
403 XmNleftPosition, TIGHTNESS * nbutton,
404 XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
405 XmATTACH_POSITION : XmATTACH_FORM,
406 XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
409 XtAddCallback( AF_ApplyButton, XmNactivateCallback,
410 (XtCallbackProc) activateCB_AF_ApplyButton,
413 /* Creation of AF_CancelButton */
414 AF_CancelButton = XtVaCreateManagedWidget( "AF_CancelButton",
415 xmPushButtonGadgetClass,
417 RES_CONVERT( XmNlabelString, GETMESSAGE(6, 12, "Cancel")),
418 XmNleftAttachment, nbutton ?
419 XmATTACH_POSITION : XmATTACH_FORM,
420 XmNleftPosition, TIGHTNESS * nbutton,
421 XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
422 XmATTACH_POSITION : XmATTACH_FORM,
423 XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
426 XtAddCallback( AF_CancelButton, XmNactivateCallback,
427 (XtCallbackProc) activateCB_AF_CancelButton,
430 /* Creation of AF_HelpButton */
431 AF_HelpButton = XtVaCreateManagedWidget( "AF_HelpButton",
432 xmPushButtonGadgetClass,
434 RES_CONVERT( XmNlabelString, GETMESSAGE(6, 13, "Help")),
435 XmNuserData, AddFiletype,
436 XmNleftAttachment, nbutton ?
437 XmATTACH_POSITION : XmATTACH_FORM,
438 XmNleftPosition, TIGHTNESS * nbutton,
439 XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
440 XmATTACH_POSITION : XmATTACH_FORM,
441 XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
444 XtAddCallback( AF_HelpButton, XmNactivateCallback,
445 (XtCallbackProc) helpCB_general,
446 (XtPointer) HELP_ADDFILETYPE );
448 /* Creation of AF_IdCharacteristicsLabel */
449 AF_IdCharacteristicsLabel = XtVaCreateManagedWidget( "AF_IdCharacteristicsLabel",
452 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 15, "Identifying Characteristics:")),
453 XmNalignment, XmALIGNMENT_BEGINNING,
455 XmNtopWidget, AF_FileTypeNameTextField,
456 XmNtopAttachment, XmATTACH_WIDGET,
458 XmNleftAttachment, XmATTACH_FORM,
460 XmNrightAttachment, XmATTACH_FORM,
463 /* Creation of AF_IdCharacteristicsText */
464 AF_IdCharacteristicsText = XtVaCreateManagedWidget( "AF_IdCharacteristicsText",
468 XmNeditMode, XmMULTI_LINE_EDIT ,
472 XmNleftAttachment, XmATTACH_FORM,
474 XmNtopWidget, AF_IdCharacteristicsLabel,
475 XmNtopAttachment, XmATTACH_WIDGET,
478 printf("AF_IdCharacteristicsText = %p\n", AF_IdCharacteristicsText);
481 /* Creation of AF_IdCharacteristicsEdit */
482 AF_IdCharacteristicsEdit = XtVaCreateManagedWidget( "AF_IdCharacteristicsEdit",
483 xmPushButtonGadgetClass,
485 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 16, "Edit...")),
486 XmNalignment, XmALIGNMENT_BEGINNING,
487 XmNmultiClick, XmMULTICLICK_DISCARD,
488 XmNnavigationType, XmTAB_GROUP,
489 XmNtraversalOn, TRUE,
491 XmNrightAttachment, XmATTACH_FORM,
492 XmNbottomWidget, AF_IdCharacteristicsText,
493 XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
495 XtAddCallback( AF_IdCharacteristicsEdit, XmNactivateCallback,
496 (XtCallbackProc) activateCB_edit_id_characteristics,
498 XtRealizeWidget(AF_IdCharacteristicsEdit);
499 XtVaGetValues(AF_IdCharacteristicsEdit, XmNwidth, &dim1, NULL);
501 XtVaSetValues(AF_IdCharacteristicsText,
502 XmNrightOffset, dim1 + 25,
503 XmNrightAttachment, XmATTACH_FORM,
506 /* Creation of AF_FiletypeIconHelpLabel */
507 AF_FiletypeIconHelpLabel = XtVaCreateManagedWidget( "AF_FiletypeIconHelpLabel",
510 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 17, "Help Text for this Datatype Icon:")),
511 XmNalignment, XmALIGNMENT_BEGINNING,
513 XmNleftAttachment, XmATTACH_FORM,
515 XmNrightAttachment, XmATTACH_FORM,
517 XmNtopWidget, AF_IdCharacteristicsText,
518 XmNtopAttachment, XmATTACH_WIDGET,
522 XtVaSetValues(AF_IdCharacteristicsText,
523 XmNrightWidget, AF_IdCharacteristicsEdit,
524 XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET,
528 /* Creation of AF_FiletypePrintCmdTextField */
529 AF_FiletypePrintCmdTextField = XtVaCreateManagedWidget( "AF_FiletypePrintCmdTextField",
530 xmTextFieldWidgetClass,
533 XmNbottomWidget, AF_OkButton,
534 XmNbottomAttachment, XmATTACH_WIDGET,
536 XmNleftAttachment, XmATTACH_FORM,
538 XmNrightAttachment, XmATTACH_FORM,
541 /* Creation of AF_FiletypePrintCmdLabel */
542 AF_FiletypePrintCmdLabel = XtVaCreateManagedWidget( "AF_FiletypePrintCmdLabel",
545 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 23, "Command to Print this Datatype:")),
546 XmNalignment, XmALIGNMENT_BEGINNING,
548 XmNbottomWidget, AF_FiletypePrintCmdTextField,
549 XmNbottomAttachment, XmATTACH_WIDGET,
551 XmNleftAttachment, XmATTACH_FORM,
553 XmNrightAttachment, XmATTACH_FORM,
556 /* Creation of AF_OpenCmdText */
557 AF_OpenCmdText = XtVaCreateManagedWidget( "AF_OpenCmdText",
562 XmNbottomWidget, AF_FiletypePrintCmdLabel,
563 XmNbottomAttachment, XmATTACH_WIDGET,
565 XmNleftAttachment, XmATTACH_FORM,
567 XmNrightAttachment, XmATTACH_FORM,
569 XmNeditMode, XmMULTI_LINE_EDIT ,
572 /* Creation of AF_OpenFiletypeCmdLabel */
573 AF_OpenFiletypeCmdLabel = XtVaCreateManagedWidget( "AF_OpenFiletypeCmdLabel",
576 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 22, "Command to Open this Datatype:")),
577 XmNalignment, XmALIGNMENT_BEGINNING,
579 XmNbottomWidget, AF_OpenCmdText,
580 XmNbottomAttachment, XmATTACH_WIDGET,
582 XmNleftAttachment, XmATTACH_FORM,
584 XmNrightAttachment, XmATTACH_FORM,
587 /* Creation of AF_CommandsLabel */
588 AF_CommandsLabel = XtVaCreateManagedWidget( "AF_CommandsLabel",
591 XmNalignment, XmALIGNMENT_BEGINNING,
592 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 21, "Commands")),
594 XmNleftAttachment, XmATTACH_FORM,
596 XmNbottomWidget, AF_OpenFiletypeCmdLabel,
597 XmNbottomAttachment, XmATTACH_WIDGET,
600 /* Creation of AF_FiletypeIconForm */
601 AF_FiletypeIconForm = XtVaCreateManagedWidget( "AF_FiletypeIconForm",
604 XmNresizePolicy, XmRESIZE_NONE,
607 XmNbottomWidget, AF_CommandsLabel,
608 XmNbottomAttachment, XmATTACH_WIDGET,
610 XmNleftAttachment, XmATTACH_FORM,
612 XmNrightAttachment, XmATTACH_FORM,
613 XmNshadowType, XmSHADOW_ETCHED_IN,
614 XmNshadowThickness, 3,
618 AF_MED_IconForm = XtVaCreateManagedWidget( "AF_MED_IconForm",
621 XmNresizePolicy, XmRESIZE_NONE,
622 XmNborderWidth, ICON_BORDER_WIDTH,
625 XmNleftAttachment, XmATTACH_POSITION,
626 XmNbottomPosition, 88,
628 XmNbottomAttachment, XmATTACH_POSITION,
631 /* Creation of AF_MED_IconGadget */
632 emptyString = XmStringCreateLocalized("");
634 pIconData = (IconData *)XtMalloc(sizeof(IconData));
635 memset(pIconData, 0, sizeof(IconData));
636 IconDataList[AF_MED] = pIconData;
637 AF_MED_IconGadget = XtVaCreateManagedWidget( "AF_MED_IconGadget",
640 XmNalignment, XmALIGNMENT_CENTER,
641 XmNuserData, pIconData,
642 XmNrecomputeSize, TRUE,
643 XmNstring, emptyString,
644 XmNleftOffset, BORDER_OFFSET,
645 XmNleftAttachment, XmATTACH_FORM,
646 XmNrightOffset, BORDER_OFFSET,
647 XmNrightAttachment, XmATTACH_FORM,
648 XmNtopOffset, BORDER_OFFSET,
649 XmNtopAttachment, XmATTACH_FORM,
650 XmNbottomOffset, BORDER_OFFSET,
651 XmNbottomAttachment, XmATTACH_FORM,
653 pIconData->wid = AF_MED_IconGadget;
654 pIconData->size = Medium_Icon;
655 XtAddCallback( AF_MED_IconGadget, XmNcallback,
656 (XtCallbackProc) activateCB_filetype_icon,
658 createCB_IconGadget(AF_MED_IconGadget, FALSE, Medium_Icon);
659 last_filetype_pushed = AF_MED_IconGadget;
661 AF_TINY_IconForm = XtVaCreateManagedWidget( "AF_TINY_IconForm",
664 XmNresizePolicy, XmRESIZE_NONE,
667 XmNleftAttachment, XmATTACH_POSITION,
668 XmNbottomPosition, 86,
670 XmNbottomAttachment, XmATTACH_POSITION,
673 /* Creation of AF_TINY_IconGadget */
674 pIconData = (IconData *)XtMalloc(sizeof(IconData));
675 memset(pIconData, 0, sizeof(IconData));
676 IconDataList[AF_TINY] = pIconData;
677 AF_TINY_IconGadget = XtVaCreateManagedWidget( "AF_TINY_IconGadget",
680 XmNalignment, XmALIGNMENT_CENTER,
681 XmNuserData, pIconData,
682 XmNrecomputeSize, TRUE,
683 XmNstring, emptyString,
684 XmNleftOffset, BORDER_OFFSET,
685 XmNleftAttachment, XmATTACH_FORM,
686 XmNrightOffset, BORDER_OFFSET,
687 XmNrightAttachment, XmATTACH_FORM,
688 XmNtopOffset, BORDER_OFFSET,
689 XmNtopAttachment, XmATTACH_FORM,
690 XmNbottomOffset, BORDER_OFFSET,
691 XmNbottomAttachment, XmATTACH_FORM,
693 pIconData->wid = AF_TINY_IconGadget;
694 pIconData->size = Tiny_Icon;
695 XtAddCallback( AF_TINY_IconGadget, XmNcallback,
696 (XtCallbackProc) activateCB_filetype_icon,
698 createCB_IconGadget(AF_TINY_IconGadget, FALSE, Tiny_Icon);
700 XmStringFree(emptyString);
702 /* Creation of AF_FiletypeIconsEditButton */
703 AF_FiletypeIconsEditButton = XtVaCreateManagedWidget( "AF_FiletypeIconsEditButton",
704 xmPushButtonGadgetClass,
706 RES_CONVERT( XmNlabelString, GETMESSAGE(6, 20, "Edit Icon...")),
707 XmNalignment, XmALIGNMENT_BEGINNING,
708 XmNmultiClick, XmMULTICLICK_DISCARD,
709 /*XmNnavigationType, XmTAB_GROUP,*/
712 XmNleftAttachment, XmATTACH_POSITION,
714 XtAddCallback( AF_FiletypeIconsEditButton, XmNactivateCallback,
715 (XtCallbackProc) activateCB_edit_icon,
716 (XtPointer) CA_FILETYPE_ICONS );
718 /* Creation of AF_FiletypeIconFindSetButton */
719 AF_FiletypeIconFindSetButton = XtVaCreateManagedWidget( "AF_FiletypeIconFindSetButton",
720 xmPushButtonGadgetClass,
724 RES_CONVERT( XmNlabelString, GETMESSAGE(6, 19, "Find Set...")),
725 XmNalignment, XmALIGNMENT_BEGINNING,
726 /*XmNnavigationType, XmTAB_GROUP,*/
727 XmNmultiClick, XmMULTICLICK_DISCARD,
730 XmNleftAttachment, XmATTACH_POSITION,
732 XtAddCallback( AF_FiletypeIconFindSetButton, XmNactivateCallback,
733 (XtCallbackProc) activateCB_open_FindSet,
734 (XtPointer) CA_FILETYPE_ICONS );
736 /******************************************************************/
737 /* Determine which button is wider, attach the short one onto it */
738 /******************************************************************/
739 XtVaGetValues(AF_FiletypeIconsEditButton, XmNwidth, &dim1, NULL);
740 XtVaGetValues(AF_FiletypeIconFindSetButton, XmNwidth, &dim2, NULL);
742 XtVaSetValues(AF_FiletypeIconFindSetButton,
746 XtVaSetValues(AF_FiletypeIconsEditButton,
750 /******************************************************************/
751 /* Determine vertical positioning for findset and edit buttons */
752 /******************************************************************/
753 /*XtRealizeWidget(AF_FiletypeIconForm);*/
754 XtVaGetValues(AF_FiletypeIconForm, XmNheight, &dim3, NULL);
755 XtVaGetValues(AF_FiletypeIconsEditButton, XmNheight, &dim1, NULL);
756 XtVaGetValues(AF_FiletypeIconFindSetButton, XmNheight, &dim2, NULL);
758 printf("find set size = %d\n", dim2);
759 printf("edit size = %d\n", dim1);
760 printf("icon area form size = %d\n", dim3);
762 if ((int)(dim1 + dim2) + 3*(FINDEDIT_SPACING) > (int)dim3) {
763 XtVaSetValues(AF_FiletypeIconsEditButton,
764 XmNbottomOffset, FINDEDIT_SPACING,
765 XmNbottomAttachment, XmATTACH_FORM,
767 XtVaSetValues(AF_FiletypeIconFindSetButton,
768 XmNbottomOffset, FINDEDIT_SPACING,
769 XmNbottomWidget, AF_FiletypeIconsEditButton,
770 XmNbottomAttachment, XmATTACH_WIDGET,
771 XmNtopOffset, FINDEDIT_SPACING,
772 XmNtopAttachment, XmATTACH_FORM,
775 XtVaSetValues(AF_FiletypeIconsEditButton,
777 XmNtopOffset, (int)(FINDEDIT_SPACING / 2),
778 XmNtopAttachment, XmATTACH_POSITION,
780 XtVaSetValues(AF_FiletypeIconFindSetButton,
781 XmNbottomPosition, 50,
782 XmNbottomOffset, (int)(FINDEDIT_SPACING / 2),
783 XmNbottomAttachment, XmATTACH_POSITION,
787 /******************************************************************/
788 /* Creation of AF_FiletypeIconsBoxLabel */
789 /******************************************************************/
790 AF_FiletypeIconsBoxLabel = XtVaCreateManagedWidget( "AF_FiletypeIconsBoxLabel",
793 RES_CONVERT( XmNlabelString, GETMESSAGE(7, 18, "Datatype Icons:")),
794 XmNalignment, XmALIGNMENT_BEGINNING,
796 XmNbottomWidget, AF_FiletypeIconForm,
797 XmNbottomAttachment, XmATTACH_WIDGET,
799 XmNleftAttachment, XmATTACH_FORM,
801 XmNrightAttachment, XmATTACH_FORM,
804 /* Creation of AF_FiletypeHelpScrolledWindow */
805 AF_FiletypeHelpScrolledWindow = XtVaCreateManagedWidget( "AF_FiletypeHelpScrolledWindow",
806 xmScrolledWindowWidgetClass,
808 XmNscrollingPolicy, XmAPPLICATION_DEFINED,
811 XmNvisualPolicy, XmVARIABLE,
812 XmNscrollBarDisplayPolicy, XmSTATIC,
813 XmNshadowThickness, 0,
815 XmNtopWidget, AF_FiletypeIconHelpLabel,
816 XmNtopAttachment, XmATTACH_WIDGET,
818 XmNbottomWidget, AF_FiletypeIconsBoxLabel,
819 XmNbottomAttachment, XmATTACH_WIDGET,
821 XmNleftAttachment, XmATTACH_FORM,
823 XmNrightAttachment, XmATTACH_FORM,
827 /* Creation of AF_FiletypeHelpText */
828 AF_FiletypeHelpText = XtVaCreateManagedWidget( "AF_FiletypeHelpText",
830 AF_FiletypeHelpScrolledWindow,
831 XmNscrollHorizontal, FALSE,
832 XmNscrollVertical, TRUE,
833 XmNeditMode, XmMULTI_LINE_EDIT ,
840 /* Creation of AF_separator2 */
841 AF_separator2 = XtVaCreateManagedWidget( "AF_separator2",
842 xmSeparatorWidgetClass,
845 XmNleftWidget, AF_CommandsLabel,
846 XmNleftAttachment, XmATTACH_WIDGET,
848 XmNrightAttachment, XmATTACH_FORM,
850 XmNbottomWidget, AF_CommandsLabel,
851 XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
855 /* Creation of AF_separator1 */
856 AF_separator1 = XtVaCreateManagedWidget( "AF_separator1",
857 xmSeparatorWidgetClass,
860 XmNbottomWidget, AF_separator2,
861 XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
863 XmNleftAttachment, XmATTACH_FORM,
865 XmNrightWidget, AF_CommandsLabel,
866 XmNrightAttachment, XmATTACH_WIDGET,
870 XtVaSetValues(AddFiletype,
871 XmNcancelButton, AF_CancelButton,
872 XmNdefaultButton, AF_OkButton,
873 XmNinitialFocus, AF_FileTypeNameTextField,
876 XtAddCallback( AddFiletype, XmNdestroyCallback,
877 (XtCallbackProc) UxDestroyContextCB,
878 (XtPointer) UxAddFiletypeContext);
881 return ( AF_BigForm );
883 return ( AddFiletype );
887 /*******************************************************************************
888 The following is the 'Interface function' which is the
889 external entry point for creating this interface.
890 This function should be called from your application or from
892 *******************************************************************************/
894 Widget create_AddFiletype(swidget _UxUxParent)
897 _UxCAddFiletype *UxContext;
898 XtArgVal /* Dimension */ dimHeight;
899 XtArgVal /* Dimension */ dimWidth;
900 XtArgVal /* Dimension */ dimTmp;
901 Widget widScrolledWindow;
904 UxAddFiletypeContext = UxContext =
905 (_UxCAddFiletype *) UxNewContext( sizeof(_UxCAddFiletype), False );
907 UxParent = _UxUxParent;
909 rtrn = _Uxbuild_AddFiletype();
911 XtRealizeWidget(rtrn);
912 XtVaGetValues (AddFiletype,
913 XmNheight, &dimHeight,
917 XmNuserData, &widScrolledWindow,
919 XtVaGetValues (widScrolledWindow,
920 XmNverticalScrollBar, &widTmp,
922 XtVaGetValues (widTmp,
929 XmNheight, dimHeight,
936 /*******************************************************************************
938 *******************************************************************************/