AddFiletype.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  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 libraries 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: AddFiletype.c /main/8 1999/09/17 15:43:02 mgreess $ */
  24. /***************************************************************************/
  25. /* */
  26. /* AddFiletype.c */
  27. /* */
  28. /* Associated Header file: AddFiletype.h */
  29. /* */
  30. /* */
  31. /***************************************************************************/
  32. #include <stdio.h>
  33. #include <sys/stat.h>
  34. #include <Xm/Xm.h>
  35. #include <Xm/MwmUtil.h>
  36. #include <Xm/DialogS.h>
  37. #include <Xm/MenuShell.h>
  38. #include <Xm/Separator.h>
  39. #include <Xm/Text.h>
  40. #include <Xm/ScrolledW.h>
  41. #include <Xm/PushB.h>
  42. #include <Xm/Form.h>
  43. #include <Xm/Text.h>
  44. #include <Xm/PushBG.h>
  45. #include <Xm/TextF.h>
  46. #include <Xm/Label.h>
  47. #include <Xm/Form.h>
  48. #include <Dt/Icon.h>
  49. #include "UxXt.h"
  50. #include "dtcreate.h"
  51. #include "af_aux.h"
  52. #include "CreateActionAppShell.h"
  53. #include "FileCharacteristics.h"
  54. #include "cmncbs.h"
  55. #define CONTEXT_MACRO_ACCESS 1
  56. #include "AddFiletype.h"
  57. #undef CONTEXT_MACRO_ACCESS
  58. /*******************************************************************************
  59. Global declarations.
  60. *******************************************************************************/
  61. /*
  62. enum mode {NONE, NEW, SAVE, QUIT};
  63. Widget activateField;
  64. Widget Licon2;
  65. extern int do_which;
  66. enum icon_size_range filetype_icon_size = None_Selected;
  67. */
  68. enum icon_size_range filetype_icon_size = None_Selected;
  69. /*******************************************************************************
  70. The following are callback functions.
  71. *******************************************************************************/
  72. #if 0
  73. /******************************************************************************/
  74. /* */
  75. /* LayoutCB_AddFiletype */
  76. /* */
  77. /* INPUT: Widget wid - window id */
  78. /* XtPointer cdata - client data */
  79. /* XtPointer *cbstruct - callback data */
  80. /* OUTPUT: none */
  81. /* */
  82. /******************************************************************************/
  83. void LayoutCB_AddFiletype(Widget wid, XtPointer cdata, XtPointer cbs)
  84. {
  85. printf("In layout callback of AddFiletype\n");
  86. }
  87. #endif
  88. /******************************************************************************/
  89. /* activateCB_edit_id_characteristics - bring up file characteristics dialog */
  90. /* INPUT: Widget filesel - edit button id */
  91. /* XtPointer cdata - client data */
  92. /* XtPointer *cbstruct - callback data */
  93. /* OUTPUT: none */
  94. /******************************************************************************/
  95. void activateCB_edit_id_characteristics (Widget filesel, XtPointer cdata,
  96. XmFileSelectionBoxCallbackStruct *cbstruct)
  97. {
  98. FiletypeData *pFtD;
  99. XtVaGetValues (AddFiletype,
  100. XmNuserData, &pFtD,
  101. NULL);
  102. /*FileCharacteristics = create_FileCharacteristics();*/
  103. XtVaSetValues (FileCharacteristics,
  104. XmNuserData, pFtD,
  105. NULL);
  106. clear_FileCharacteristics_dialog_fields();
  107. init_FileCharacteristics_dialog_fields(pFtD);
  108. UxPopupInterface (FILE_CHARACTERISTICS, no_grab);
  109. return;
  110. }
  111. static void activateCB_AF_OkButton( Widget UxWidget,
  112. XtPointer UxClientData,
  113. XtPointer UxCallbackArg)
  114. {
  115. FiletypeData *pFtD;
  116. FiletypeData **papArray;
  117. int i;
  118. /**************************************************************************/
  119. /* Check if fields are valid. */
  120. /**************************************************************************/
  121. if (!AddFiletypeCheckFields()) {
  122. /***********************************************************************/
  123. /* Get FiletypeData structure that was allocated when Add button on */
  124. /* the CreateActionAppShell interface was activated. */
  125. /***********************************************************************/
  126. XtVaGetValues(AddFiletype, XmNuserData, &pFtD, NULL);
  127. /***********************************************************************/
  128. /* Get all values from gui */
  129. /***********************************************************************/
  130. readAFFromGUI(pFtD);
  131. /***********************************************************************/
  132. /* If in edit mode, then don't do add type things. */
  133. /***********************************************************************/
  134. if (!(pFtD->fsInternal & CA_FT_EDIT)) {
  135. /********************************************************************/
  136. /* Update the Filetype listbox with this new filetype */
  137. /********************************************************************/
  138. AddFiletypeToList();
  139. /********************************************************************/
  140. /* Update FiletypeData array within the ActionData structure */
  141. /********************************************************************/
  142. UpdateFiletypeDataArray(pFtD);
  143. }
  144. /***********************************************************************/
  145. /* Unset previous set values. */
  146. /***********************************************************************/
  147. pFtD->fsInternal &= (~(CA_FT_APPLY));
  148. pFtD->fsInternal &= (~(CA_FT_EDIT));
  149. /***********************************************************************/
  150. /* Pop down the AddFiletype interface */
  151. /***********************************************************************/
  152. UxPopdownInterface(AddFiletype);
  153. }
  154. }
  155. static void activateCB_AF_ApplyButton( Widget UxWidget,
  156. XtPointer UxClientData,
  157. XtPointer UxCallbackArg)
  158. {
  159. FiletypeData *pFtD;
  160. /**************************************************************************/
  161. /* Check if fields are valid. */
  162. /**************************************************************************/
  163. if (!AddFiletypeCheckFields()) {
  164. /***********************************************************************/
  165. /* Get FiletypeData structure that was allocated when Add button on */
  166. /* the CreateActionAppShell interface was activated. */
  167. /***********************************************************************/
  168. XtVaGetValues(AddFiletype, XmNuserData, &pFtD, NULL);
  169. /***********************************************************************/
  170. /* Get all values from gui */
  171. /***********************************************************************/
  172. readAFFromGUI(pFtD);
  173. /***********************************************************************/
  174. /* Set the variable that indicates that Apply button was used. */
  175. /***********************************************************************/
  176. pFtD->fsInternal |= CA_FT_APPLY;
  177. /***********************************************************************/
  178. /* If in edit mode, then don't do apply type things. */
  179. /***********************************************************************/
  180. if (!(pFtD->fsInternal & CA_FT_EDIT)) {
  181. /********************************************************************/
  182. /* Update the Filetype listbox with this new filetype */
  183. /********************************************************************/
  184. if (XmListItemExists(CA_FiletypesList, XmStringCreateSimple("NONE"))) {
  185. XmListDeleteItem(CA_FiletypesList, XmStringCreateSimple("NONE"));
  186. }
  187. AddFiletypeToList();
  188. /********************************************************************/
  189. /* Update FiletypeData array within the ActionData structure */
  190. /********************************************************************/
  191. UpdateFiletypeDataArray(pFtD);
  192. }
  193. }
  194. }
  195. static void activateCB_AF_CancelButton( Widget UxWidget,
  196. XtPointer UxClientData,
  197. XtPointer UxCallbackArg)
  198. {
  199. FiletypeData *pFtD;
  200. UxPopdownInterface(AddFiletype);
  201. XtVaGetValues(AddFiletype, XmNuserData, &pFtD, NULL);
  202. if (!((pFtD->fsInternal & CA_FT_APPLY) || (pFtD->fsInternal & CA_FT_EDIT))) {
  203. free_Filetypedata(pFtD);
  204. } else {
  205. pFtD->fsInternal &= (~(CA_FT_APPLY));
  206. pFtD->fsInternal &= (~(CA_FT_EDIT));
  207. }
  208. }
  209. /*******************************************************************************
  210. The 'build_' function creates all the widgets
  211. using the resource values specified in the Property Editor.
  212. *******************************************************************************/
  213. static Widget _Uxbuild_AddFiletype(void)
  214. {
  215. Widget _UxParent;
  216. char *UxTmp0;
  217. Widget AF_CharacteristicsWindow;
  218. Widget ActionAreaForm;
  219. int ntotalbuttons = 4;
  220. int nbutton = 0;
  221. Widget AF_ScrolledWindow;
  222. Widget AF_BigForm = NULL;
  223. XtArgVal /* Dimension */ dim1, dim2, dim3;
  224. Widget AF_MED_IconForm, AF_TINY_IconForm;
  225. IconData *pIconData;
  226. char *pre, *suf, *title;
  227. XmString emptyString;
  228. size_t len;
  229. #define TIGHTNESS 20
  230. #define ICON_MIN_HEIGHT 83
  231. #define FINDEDIT_SPACING 6
  232. #define BORDER_OFFSET 3
  233. /* Creation of AddFiletype */
  234. _UxParent = UxParent;
  235. if ( _UxParent == NULL )
  236. {
  237. _UxParent = UxTopLevel;
  238. }
  239. pre = GETMESSAGE(3, 10, "Create Action");
  240. suf = GETMESSAGE(7, 10, "Add Datatype");
  241. len = strlen(pre) + strlen(suf) + 4;
  242. title = XtMalloc(len);
  243. snprintf(title,len - 1, "%s - %s", pre, suf);
  244. _UxParent = XtVaCreatePopupShell( "AddFiletype_shell",
  245. xmDialogShellWidgetClass, _UxParent,
  246. XmNx, 422,
  247. XmNy, 148,
  248. XmNshellUnitType, XmPIXELS,
  249. XmNtitle, title,
  250. NULL );
  251. /*
  252. XtAddCallback(_UxParent, XmNpopupCallback, LayoutCB_AddFiletype, NULL);
  253. */
  254. if (bLowRes) {
  255. AF_BigForm = XtVaCreateWidget( "AF_BigForm",
  256. xmFormWidgetClass,
  257. _UxParent,
  258. XmNunitType, XmPIXELS,
  259. XmNdialogStyle, XmDIALOG_APPLICATION_MODAL,
  260. RES_CONVERT( XmNdialogTitle, title ),
  261. XmNautoUnmanage, FALSE,
  262. NULL );
  263. AF_ScrolledWindow = XtVaCreateManagedWidget( "AF_ScrolledWindow",
  264. xmScrolledWindowWidgetClass,
  265. AF_BigForm,
  266. XmNscrollingPolicy, XmAUTOMATIC,
  267. XmNleftAttachment, XmATTACH_FORM,
  268. XmNrightAttachment, XmATTACH_FORM,
  269. XmNbottomAttachment, XmATTACH_FORM,
  270. XmNtopAttachment, XmATTACH_FORM,
  271. NULL );
  272. XtVaSetValues(AF_BigForm, XmNuserData, AF_ScrolledWindow, NULL);
  273. AddFiletype = XtVaCreateManagedWidget( "AddFiletype",
  274. xmFormWidgetClass,
  275. AF_ScrolledWindow,
  276. NULL );
  277. } else {
  278. AddFiletype = XtVaCreateWidget( "AddFiletype",
  279. xmFormWidgetClass,
  280. _UxParent,
  281. XmNunitType, XmPIXELS,
  282. XmNdialogStyle, XmDIALOG_APPLICATION_MODAL,
  283. RES_CONVERT( XmNdialogTitle, title ),
  284. XmNautoUnmanage, FALSE,
  285. NULL );
  286. }
  287. XtFree(title);
  288. XtAddCallback( AddFiletype, XmNhelpCallback,
  289. (XtCallbackProc) helpCB_general,
  290. (XtPointer) HELP_ADDFILETYPE );
  291. /* Creation of AF_FiletypeFamilyNameLabel */
  292. AF_FiletypeFamilyNameLabel = XtVaCreateManagedWidget( "AF_FiletypeFamilyNameLabel",
  293. xmLabelWidgetClass,
  294. AddFiletype,
  295. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 14, "Name of Datatype Family:")),
  296. XmNalignment, XmALIGNMENT_BEGINNING,
  297. XmNtopOffset, 15,
  298. XmNtopAttachment, XmATTACH_FORM,
  299. XmNleftOffset, 10,
  300. XmNleftAttachment, XmATTACH_FORM,
  301. XmNrightOffset, 10,
  302. XmNrightAttachment, XmATTACH_FORM,
  303. NULL );
  304. /* Creation of AF_FileTypeNameTextField */
  305. AF_FileTypeNameTextField = XtVaCreateManagedWidget( "AF_FileTypeNameTextField",
  306. xmTextFieldWidgetClass,
  307. AddFiletype,
  308. XmNtopOffset, 0,
  309. XmNtopWidget, AF_FiletypeFamilyNameLabel,
  310. XmNtopAttachment, XmATTACH_WIDGET,
  311. XmNleftOffset, 10,
  312. XmNleftAttachment, XmATTACH_FORM,
  313. XmNrightOffset, 10,
  314. XmNrightAttachment, XmATTACH_FORM,
  315. NULL );
  316. ActionAreaForm = XtVaCreateManagedWidget( "ActionAreaForm",
  317. xmFormWidgetClass,
  318. AddFiletype,
  319. XmNnavigationType, XmTAB_GROUP,
  320. XmNskipAdjust, TRUE,
  321. XmNfractionBase, ((TIGHTNESS * ntotalbuttons) - 1),
  322. XmNleftOffset, 10,
  323. XmNleftAttachment, XmATTACH_FORM,
  324. XmNrightOffset, 10,
  325. XmNrightAttachment, XmATTACH_FORM,
  326. XmNbottomOffset, 20,
  327. XmNbottomAttachment, XmATTACH_FORM,
  328. NULL );
  329. /* Creation of AF_OkButton */
  330. AF_OkButton = XtVaCreateManagedWidget( "AF_OkButton",
  331. xmPushButtonGadgetClass,
  332. ActionAreaForm,
  333. RES_CONVERT( XmNlabelString, GETMESSAGE(6, 10, "OK")),
  334. XmNmultiClick, XmMULTICLICK_DISCARD,
  335. XmNleftAttachment, nbutton ?
  336. XmATTACH_POSITION : XmATTACH_FORM,
  337. XmNleftPosition, TIGHTNESS * nbutton,
  338. XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
  339. XmATTACH_POSITION : XmATTACH_FORM,
  340. XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
  341. NULL );
  342. nbutton++;
  343. XtAddCallback( AF_OkButton, XmNactivateCallback,
  344. (XtCallbackProc) activateCB_AF_OkButton,
  345. (XtPointer) NULL );
  346. /* Creation of AF_ApplyButton */
  347. AF_ApplyButton = XtVaCreateManagedWidget( "AF_ApplyButton",
  348. xmPushButtonGadgetClass,
  349. ActionAreaForm,
  350. RES_CONVERT( XmNlabelString, GETMESSAGE(6, 11, "Apply")),
  351. XmNleftAttachment, nbutton ?
  352. XmATTACH_POSITION : XmATTACH_FORM,
  353. XmNleftPosition, TIGHTNESS * nbutton,
  354. XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
  355. XmATTACH_POSITION : XmATTACH_FORM,
  356. XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
  357. NULL );
  358. nbutton++;
  359. XtAddCallback( AF_ApplyButton, XmNactivateCallback,
  360. (XtCallbackProc) activateCB_AF_ApplyButton,
  361. (XtPointer) NULL );
  362. /* Creation of AF_CancelButton */
  363. AF_CancelButton = XtVaCreateManagedWidget( "AF_CancelButton",
  364. xmPushButtonGadgetClass,
  365. ActionAreaForm,
  366. RES_CONVERT( XmNlabelString, GETMESSAGE(6, 12, "Cancel")),
  367. XmNleftAttachment, nbutton ?
  368. XmATTACH_POSITION : XmATTACH_FORM,
  369. XmNleftPosition, TIGHTNESS * nbutton,
  370. XmNrightAttachment, nbutton != (ntotalbuttons - 1) ?
  371. XmATTACH_POSITION : XmATTACH_FORM,
  372. XmNrightPosition, (TIGHTNESS * nbutton)+(TIGHTNESS - 1),
  373. NULL );
  374. nbutton++;
  375. XtAddCallback( AF_CancelButton, XmNactivateCallback,
  376. (XtCallbackProc) activateCB_AF_CancelButton,
  377. (XtPointer) NULL );
  378. /* Creation of AF_HelpButton */
  379. AF_HelpButton = XtVaCreateManagedWidget( "AF_HelpButton",
  380. xmPushButtonGadgetClass,
  381. ActionAreaForm,
  382. RES_CONVERT( XmNlabelString, GETMESSAGE(6, 13, "Help")),
  383. XmNuserData, AddFiletype,
  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),
  390. NULL );
  391. nbutton++;
  392. XtAddCallback( AF_HelpButton, XmNactivateCallback,
  393. (XtCallbackProc) helpCB_general,
  394. (XtPointer) HELP_ADDFILETYPE );
  395. /* Creation of AF_IdCharacteristicsLabel */
  396. AF_IdCharacteristicsLabel = XtVaCreateManagedWidget( "AF_IdCharacteristicsLabel",
  397. xmLabelWidgetClass,
  398. AddFiletype,
  399. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 15, "Identifying Characteristics:")),
  400. XmNalignment, XmALIGNMENT_BEGINNING,
  401. XmNtopOffset, 10,
  402. XmNtopWidget, AF_FileTypeNameTextField,
  403. XmNtopAttachment, XmATTACH_WIDGET,
  404. XmNleftOffset, 10,
  405. XmNleftAttachment, XmATTACH_FORM,
  406. XmNrightOffset, 10,
  407. XmNrightAttachment, XmATTACH_FORM,
  408. NULL );
  409. /* Creation of AF_IdCharacteristicsText */
  410. AF_IdCharacteristicsText = XtVaCreateManagedWidget( "AF_IdCharacteristicsText",
  411. xmTextWidgetClass,
  412. AddFiletype,
  413. XmNheight, 90,
  414. XmNeditMode, XmMULTI_LINE_EDIT ,
  415. XmNeditable, FALSE,
  416. XmNrows, 3,
  417. XmNleftOffset, 10,
  418. XmNleftAttachment, XmATTACH_FORM,
  419. XmNtopOffset, 0,
  420. XmNtopWidget, AF_IdCharacteristicsLabel,
  421. XmNtopAttachment, XmATTACH_WIDGET,
  422. NULL );
  423. #ifdef DEBUG
  424. printf("AF_IdCharacteristicsText = %p\n", AF_IdCharacteristicsText);
  425. #endif
  426. /* Creation of AF_IdCharacteristicsEdit */
  427. AF_IdCharacteristicsEdit = XtVaCreateManagedWidget( "AF_IdCharacteristicsEdit",
  428. xmPushButtonGadgetClass,
  429. AddFiletype,
  430. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 16, "Edit...")),
  431. XmNalignment, XmALIGNMENT_BEGINNING,
  432. XmNmultiClick, XmMULTICLICK_DISCARD,
  433. XmNnavigationType, XmTAB_GROUP,
  434. XmNtraversalOn, TRUE,
  435. XmNrightOffset, 10,
  436. XmNrightAttachment, XmATTACH_FORM,
  437. XmNbottomWidget, AF_IdCharacteristicsText,
  438. XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
  439. NULL );
  440. XtAddCallback( AF_IdCharacteristicsEdit, XmNactivateCallback,
  441. (XtCallbackProc) activateCB_edit_id_characteristics,
  442. (XtPointer) NULL );
  443. XtRealizeWidget(AF_IdCharacteristicsEdit);
  444. XtVaGetValues(AF_IdCharacteristicsEdit, XmNwidth, &dim1, NULL);
  445. XtVaSetValues(AF_IdCharacteristicsText,
  446. XmNrightOffset, dim1 + 25,
  447. XmNrightAttachment, XmATTACH_FORM,
  448. NULL);
  449. /* Creation of AF_FiletypeIconHelpLabel */
  450. AF_FiletypeIconHelpLabel = XtVaCreateManagedWidget( "AF_FiletypeIconHelpLabel",
  451. xmLabelWidgetClass,
  452. AddFiletype,
  453. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 17, "Help Text for this Datatype Icon:")),
  454. XmNalignment, XmALIGNMENT_BEGINNING,
  455. XmNleftOffset, 10,
  456. XmNleftAttachment, XmATTACH_FORM,
  457. XmNrightOffset, 10,
  458. XmNrightAttachment, XmATTACH_FORM,
  459. XmNtopOffset, 10,
  460. XmNtopWidget, AF_IdCharacteristicsText,
  461. XmNtopAttachment, XmATTACH_WIDGET,
  462. NULL );
  463. /*
  464. XtVaSetValues(AF_IdCharacteristicsText,
  465. XmNrightWidget, AF_IdCharacteristicsEdit,
  466. XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET,
  467. NULL);
  468. */
  469. /* Creation of AF_FiletypePrintCmdTextField */
  470. AF_FiletypePrintCmdTextField = XtVaCreateManagedWidget( "AF_FiletypePrintCmdTextField",
  471. xmTextFieldWidgetClass,
  472. AddFiletype,
  473. XmNbottomOffset, 15,
  474. XmNbottomWidget, AF_OkButton,
  475. XmNbottomAttachment, XmATTACH_WIDGET,
  476. XmNleftOffset, 10,
  477. XmNleftAttachment, XmATTACH_FORM,
  478. XmNrightOffset, 10,
  479. XmNrightAttachment, XmATTACH_FORM,
  480. NULL );
  481. /* Creation of AF_FiletypePrintCmdLabel */
  482. AF_FiletypePrintCmdLabel = XtVaCreateManagedWidget( "AF_FiletypePrintCmdLabel",
  483. xmLabelWidgetClass,
  484. AddFiletype,
  485. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 23, "Command to Print this Datatype:")),
  486. XmNalignment, XmALIGNMENT_BEGINNING,
  487. XmNbottomOffset, 0,
  488. XmNbottomWidget, AF_FiletypePrintCmdTextField,
  489. XmNbottomAttachment, XmATTACH_WIDGET,
  490. XmNleftOffset, 10,
  491. XmNleftAttachment, XmATTACH_FORM,
  492. XmNrightOffset, 10,
  493. XmNrightAttachment, XmATTACH_FORM,
  494. NULL );
  495. /* Creation of AF_OpenCmdText */
  496. AF_OpenCmdText = XtVaCreateManagedWidget( "AF_OpenCmdText",
  497. xmTextWidgetClass,
  498. AddFiletype,
  499. XmNeditable, FALSE,
  500. XmNbottomOffset, 15,
  501. XmNbottomWidget, AF_FiletypePrintCmdLabel,
  502. XmNbottomAttachment, XmATTACH_WIDGET,
  503. XmNleftOffset, 10,
  504. XmNleftAttachment, XmATTACH_FORM,
  505. XmNrightOffset, 10,
  506. XmNrightAttachment, XmATTACH_FORM,
  507. XmNrows, 1,
  508. XmNeditMode, XmMULTI_LINE_EDIT ,
  509. NULL );
  510. /* Creation of AF_OpenFiletypeCmdLabel */
  511. AF_OpenFiletypeCmdLabel = XtVaCreateManagedWidget( "AF_OpenFiletypeCmdLabel",
  512. xmLabelWidgetClass,
  513. AddFiletype,
  514. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 22, "Command to Open this Datatype:")),
  515. XmNalignment, XmALIGNMENT_BEGINNING,
  516. XmNbottomOffset, 0,
  517. XmNbottomWidget, AF_OpenCmdText,
  518. XmNbottomAttachment, XmATTACH_WIDGET,
  519. XmNleftOffset, 10,
  520. XmNleftAttachment, XmATTACH_FORM,
  521. XmNrightOffset, 10,
  522. XmNrightAttachment, XmATTACH_FORM,
  523. NULL );
  524. /* Creation of AF_CommandsLabel */
  525. AF_CommandsLabel = XtVaCreateManagedWidget( "AF_CommandsLabel",
  526. xmLabelWidgetClass,
  527. AddFiletype,
  528. XmNalignment, XmALIGNMENT_BEGINNING,
  529. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 21, "Commands")),
  530. XmNleftOffset, 10,
  531. XmNleftAttachment, XmATTACH_FORM,
  532. XmNbottomOffset, 15,
  533. XmNbottomWidget, AF_OpenFiletypeCmdLabel,
  534. XmNbottomAttachment, XmATTACH_WIDGET,
  535. NULL );
  536. /* Creation of AF_FiletypeIconForm */
  537. AF_FiletypeIconForm = XtVaCreateManagedWidget( "AF_FiletypeIconForm",
  538. xmFormWidgetClass,
  539. AddFiletype,
  540. XmNresizePolicy, XmRESIZE_NONE,
  541. XmNborderWidth, 0,
  542. XmNbottomOffset, 20,
  543. XmNbottomWidget, AF_CommandsLabel,
  544. XmNbottomAttachment, XmATTACH_WIDGET,
  545. XmNleftOffset, 10,
  546. XmNleftAttachment, XmATTACH_FORM,
  547. XmNrightOffset, 10,
  548. XmNrightAttachment, XmATTACH_FORM,
  549. XmNshadowType, XmSHADOW_ETCHED_IN,
  550. XmNshadowThickness, 3,
  551. XmNheight, 90,
  552. NULL );
  553. AF_MED_IconForm = XtVaCreateManagedWidget( "AF_MED_IconForm",
  554. xmFormWidgetClass,
  555. AF_FiletypeIconForm,
  556. XmNresizePolicy, XmRESIZE_NONE,
  557. XmNborderWidth, ICON_BORDER_WIDTH,
  558. XmNleftPosition, 16,
  559. XmNleftOffset, 0,
  560. XmNleftAttachment, XmATTACH_POSITION,
  561. XmNbottomPosition, 88,
  562. XmNbottomOffset, 0,
  563. XmNbottomAttachment, XmATTACH_POSITION,
  564. NULL );
  565. /* Creation of AF_MED_IconGadget */
  566. emptyString = XmStringCreateLocalized("");
  567. pIconData = (IconData *)XtMalloc(sizeof(IconData));
  568. memset(pIconData, 0, sizeof(IconData));
  569. IconDataList[AF_MED] = pIconData;
  570. AF_MED_IconGadget = XtVaCreateManagedWidget( "AF_MED_IconGadget",
  571. dtIconGadgetClass,
  572. AF_MED_IconForm,
  573. XmNalignment, XmALIGNMENT_CENTER,
  574. XmNuserData, pIconData,
  575. XmNrecomputeSize, TRUE,
  576. XmNstring, emptyString,
  577. XmNleftOffset, BORDER_OFFSET,
  578. XmNleftAttachment, XmATTACH_FORM,
  579. XmNrightOffset, BORDER_OFFSET,
  580. XmNrightAttachment, XmATTACH_FORM,
  581. XmNtopOffset, BORDER_OFFSET,
  582. XmNtopAttachment, XmATTACH_FORM,
  583. XmNbottomOffset, BORDER_OFFSET,
  584. XmNbottomAttachment, XmATTACH_FORM,
  585. NULL );
  586. pIconData->wid = AF_MED_IconGadget;
  587. pIconData->size = Medium_Icon;
  588. XtAddCallback( AF_MED_IconGadget, XmNcallback,
  589. (XtCallbackProc) activateCB_filetype_icon,
  590. (XtPointer) NULL );
  591. createCB_IconGadget(AF_MED_IconGadget, FALSE, Medium_Icon);
  592. last_filetype_pushed = AF_MED_IconGadget;
  593. AF_TINY_IconForm = XtVaCreateManagedWidget( "AF_TINY_IconForm",
  594. xmFormWidgetClass,
  595. AF_FiletypeIconForm,
  596. XmNresizePolicy, XmRESIZE_NONE,
  597. XmNleftPosition, 41,
  598. XmNleftOffset, -1,
  599. XmNleftAttachment, XmATTACH_POSITION,
  600. XmNbottomPosition, 86,
  601. XmNbottomOffset, 0,
  602. XmNbottomAttachment, XmATTACH_POSITION,
  603. NULL );
  604. /* Creation of AF_TINY_IconGadget */
  605. pIconData = (IconData *)XtMalloc(sizeof(IconData));
  606. memset(pIconData, 0, sizeof(IconData));
  607. IconDataList[AF_TINY] = pIconData;
  608. AF_TINY_IconGadget = XtVaCreateManagedWidget( "AF_TINY_IconGadget",
  609. dtIconGadgetClass,
  610. AF_TINY_IconForm,
  611. XmNalignment, XmALIGNMENT_CENTER,
  612. XmNuserData, pIconData,
  613. XmNrecomputeSize, TRUE,
  614. XmNstring, emptyString,
  615. XmNleftOffset, BORDER_OFFSET,
  616. XmNleftAttachment, XmATTACH_FORM,
  617. XmNrightOffset, BORDER_OFFSET,
  618. XmNrightAttachment, XmATTACH_FORM,
  619. XmNtopOffset, BORDER_OFFSET,
  620. XmNtopAttachment, XmATTACH_FORM,
  621. XmNbottomOffset, BORDER_OFFSET,
  622. XmNbottomAttachment, XmATTACH_FORM,
  623. NULL );
  624. pIconData->wid = AF_TINY_IconGadget;
  625. pIconData->size = Tiny_Icon;
  626. XtAddCallback( AF_TINY_IconGadget, XmNcallback,
  627. (XtCallbackProc) activateCB_filetype_icon,
  628. (XtPointer) NULL );
  629. createCB_IconGadget(AF_TINY_IconGadget, FALSE, Tiny_Icon);
  630. XmStringFree(emptyString);
  631. /* Creation of AF_FiletypeIconsEditButton */
  632. AF_FiletypeIconsEditButton = XtVaCreateManagedWidget( "AF_FiletypeIconsEditButton",
  633. xmPushButtonGadgetClass,
  634. AF_FiletypeIconForm,
  635. RES_CONVERT( XmNlabelString, GETMESSAGE(6, 20, "Edit Icon...")),
  636. XmNalignment, XmALIGNMENT_BEGINNING,
  637. XmNmultiClick, XmMULTICLICK_DISCARD,
  638. /*XmNnavigationType, XmTAB_GROUP,*/
  639. XmNleftPosition, 64,
  640. XmNleftOffset, -1,
  641. XmNleftAttachment, XmATTACH_POSITION,
  642. NULL );
  643. XtAddCallback( AF_FiletypeIconsEditButton, XmNactivateCallback,
  644. (XtCallbackProc) activateCB_edit_icon,
  645. (XtPointer) CA_FILETYPE_ICONS );
  646. /* Creation of AF_FiletypeIconFindSetButton */
  647. AF_FiletypeIconFindSetButton = XtVaCreateManagedWidget( "AF_FiletypeIconFindSetButton",
  648. xmPushButtonGadgetClass,
  649. AF_FiletypeIconForm,
  650. XmNx, 290,
  651. XmNy, 20,
  652. RES_CONVERT( XmNlabelString, GETMESSAGE(6, 19, "Find Set...")),
  653. XmNalignment, XmALIGNMENT_BEGINNING,
  654. /*XmNnavigationType, XmTAB_GROUP,*/
  655. XmNmultiClick, XmMULTICLICK_DISCARD,
  656. XmNleftPosition, 64,
  657. XmNleftOffset, -1,
  658. XmNleftAttachment, XmATTACH_POSITION,
  659. NULL );
  660. XtAddCallback( AF_FiletypeIconFindSetButton, XmNactivateCallback,
  661. (XtCallbackProc) activateCB_open_FindSet,
  662. (XtPointer) CA_FILETYPE_ICONS );
  663. /******************************************************************/
  664. /* Determine which button is wider, attach the short one onto it */
  665. /******************************************************************/
  666. XtVaGetValues(AF_FiletypeIconsEditButton, XmNwidth, &dim1, NULL);
  667. XtVaGetValues(AF_FiletypeIconFindSetButton, XmNwidth, &dim2, NULL);
  668. if (dim1 > dim2) {
  669. XtVaSetValues(AF_FiletypeIconFindSetButton,
  670. XmNwidth, dim1,
  671. NULL);
  672. } else {
  673. XtVaSetValues(AF_FiletypeIconsEditButton,
  674. XmNwidth, dim2,
  675. NULL);
  676. }
  677. /******************************************************************/
  678. /* Determine vertical positioning for findset and edit buttons */
  679. /******************************************************************/
  680. /*XtRealizeWidget(AF_FiletypeIconForm);*/
  681. XtVaGetValues(AF_FiletypeIconForm, XmNheight, &dim3, NULL);
  682. XtVaGetValues(AF_FiletypeIconsEditButton, XmNheight, &dim1, NULL);
  683. XtVaGetValues(AF_FiletypeIconFindSetButton, XmNheight, &dim2, NULL);
  684. #ifdef DEBUG
  685. printf("find set size = %d\n", dim2);
  686. printf("edit size = %d\n", dim1);
  687. printf("icon area form size = %d\n", dim3);
  688. #endif
  689. if ((int)(dim1 + dim2) + 3*(FINDEDIT_SPACING) > (int)dim3) {
  690. XtVaSetValues(AF_FiletypeIconsEditButton,
  691. XmNbottomOffset, FINDEDIT_SPACING,
  692. XmNbottomAttachment, XmATTACH_FORM,
  693. NULL);
  694. XtVaSetValues(AF_FiletypeIconFindSetButton,
  695. XmNbottomOffset, FINDEDIT_SPACING,
  696. XmNbottomWidget, AF_FiletypeIconsEditButton,
  697. XmNbottomAttachment, XmATTACH_WIDGET,
  698. XmNtopOffset, FINDEDIT_SPACING,
  699. XmNtopAttachment, XmATTACH_FORM,
  700. NULL);
  701. } else {
  702. XtVaSetValues(AF_FiletypeIconsEditButton,
  703. XmNtopPosition, 50,
  704. XmNtopOffset, (int)(FINDEDIT_SPACING / 2),
  705. XmNtopAttachment, XmATTACH_POSITION,
  706. NULL);
  707. XtVaSetValues(AF_FiletypeIconFindSetButton,
  708. XmNbottomPosition, 50,
  709. XmNbottomOffset, (int)(FINDEDIT_SPACING / 2),
  710. XmNbottomAttachment, XmATTACH_POSITION,
  711. NULL);
  712. }
  713. /******************************************************************/
  714. /* Creation of AF_FiletypeIconsBoxLabel */
  715. /******************************************************************/
  716. AF_FiletypeIconsBoxLabel = XtVaCreateManagedWidget( "AF_FiletypeIconsBoxLabel",
  717. xmLabelWidgetClass,
  718. AddFiletype,
  719. RES_CONVERT( XmNlabelString, GETMESSAGE(7, 18, "Datatype Icons:")),
  720. XmNalignment, XmALIGNMENT_BEGINNING,
  721. XmNbottomOffset, 0,
  722. XmNbottomWidget, AF_FiletypeIconForm,
  723. XmNbottomAttachment, XmATTACH_WIDGET,
  724. XmNleftOffset, 10,
  725. XmNleftAttachment, XmATTACH_FORM,
  726. XmNrightOffset, 10,
  727. XmNrightAttachment, XmATTACH_FORM,
  728. NULL );
  729. /* Creation of AF_FiletypeHelpScrolledWindow */
  730. AF_FiletypeHelpScrolledWindow = XtVaCreateManagedWidget( "AF_FiletypeHelpScrolledWindow",
  731. xmScrolledWindowWidgetClass,
  732. AddFiletype,
  733. XmNscrollingPolicy, XmAPPLICATION_DEFINED,
  734. XmNx, 10,
  735. XmNy, 226,
  736. XmNvisualPolicy, XmVARIABLE,
  737. XmNscrollBarDisplayPolicy, XmSTATIC,
  738. XmNshadowThickness, 0,
  739. XmNtopOffset, 0,
  740. XmNtopWidget, AF_FiletypeIconHelpLabel,
  741. XmNtopAttachment, XmATTACH_WIDGET,
  742. XmNbottomOffset, 10,
  743. XmNbottomWidget, AF_FiletypeIconsBoxLabel,
  744. XmNbottomAttachment, XmATTACH_WIDGET,
  745. XmNleftOffset, 10,
  746. XmNleftAttachment, XmATTACH_FORM,
  747. XmNrightOffset, 10,
  748. XmNrightAttachment, XmATTACH_FORM,
  749. XmNheight, 94,
  750. NULL );
  751. /* Creation of AF_FiletypeHelpText */
  752. AF_FiletypeHelpText = XtVaCreateManagedWidget( "AF_FiletypeHelpText",
  753. xmTextWidgetClass,
  754. AF_FiletypeHelpScrolledWindow,
  755. XmNscrollHorizontal, FALSE,
  756. XmNscrollVertical, TRUE,
  757. XmNeditMode, XmMULTI_LINE_EDIT ,
  758. XmNwordWrap, TRUE,
  759. XmNx, 19,
  760. XmNy, 0,
  761. XmNheight, 80,
  762. NULL );
  763. /* Creation of AF_separator2 */
  764. AF_separator2 = XtVaCreateManagedWidget( "AF_separator2",
  765. xmSeparatorWidgetClass,
  766. AddFiletype,
  767. XmNleftOffset, 0,
  768. XmNleftWidget, AF_CommandsLabel,
  769. XmNleftAttachment, XmATTACH_WIDGET,
  770. XmNrightOffset, 10,
  771. XmNrightAttachment, XmATTACH_FORM,
  772. XmNbottomOffset, 10,
  773. XmNbottomWidget, AF_CommandsLabel,
  774. XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
  775. NULL );
  776. #if 0
  777. /* Creation of AF_separator1 */
  778. AF_separator1 = XtVaCreateManagedWidget( "AF_separator1",
  779. xmSeparatorWidgetClass,
  780. AddFiletype,
  781. XmNbottomOffset, 0,
  782. XmNbottomWidget, AF_separator2,
  783. XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
  784. XmNleftOffset, 10,
  785. XmNleftAttachment, XmATTACH_FORM,
  786. XmNrightOffset, 0,
  787. XmNrightWidget, AF_CommandsLabel,
  788. XmNrightAttachment, XmATTACH_WIDGET,
  789. NULL );
  790. #endif
  791. XtVaSetValues(AddFiletype,
  792. XmNcancelButton, AF_CancelButton,
  793. XmNdefaultButton, AF_OkButton,
  794. XmNinitialFocus, AF_FileTypeNameTextField,
  795. NULL );
  796. XtAddCallback( AddFiletype, XmNdestroyCallback,
  797. (XtCallbackProc) UxDestroyContextCB,
  798. (XtPointer) UxAddFiletypeContext);
  799. if (bLowRes) {
  800. return ( AF_BigForm );
  801. } else {
  802. return ( AddFiletype );
  803. }
  804. }
  805. /*******************************************************************************
  806. The following is the 'Interface function' which is the
  807. external entry point for creating this interface.
  808. This function should be called from your application or from
  809. a callback function.
  810. *******************************************************************************/
  811. Widget create_AddFiletype(swidget _UxUxParent)
  812. {
  813. Widget rtrn;
  814. _UxCAddFiletype *UxContext;
  815. XtArgVal /* Dimension */ dimHeight;
  816. XtArgVal /* Dimension */ dimWidth;
  817. XtArgVal /* Dimension */ dimTmp;
  818. Widget widScrolledWindow;
  819. Widget widTmp;
  820. UxAddFiletypeContext = UxContext =
  821. (_UxCAddFiletype *) UxNewContext( sizeof(_UxCAddFiletype), False );
  822. UxParent = _UxUxParent;
  823. rtrn = _Uxbuild_AddFiletype();
  824. if (bLowRes) {
  825. XtRealizeWidget(rtrn);
  826. XtVaGetValues (AddFiletype,
  827. XmNheight, &dimHeight,
  828. XmNwidth, &dimWidth,
  829. NULL);
  830. XtVaGetValues (rtrn,
  831. XmNuserData, &widScrolledWindow,
  832. NULL);
  833. XtVaGetValues (widScrolledWindow,
  834. XmNverticalScrollBar, &widTmp,
  835. NULL);
  836. XtVaGetValues (widTmp,
  837. XmNwidth, &dimTmp,
  838. NULL);
  839. dimHeight += dimTmp;
  840. dimWidth += dimTmp;
  841. XtVaSetValues (rtrn,
  842. XmNheight, dimHeight,
  843. XmNwidth, dimWidth,
  844. NULL);
  845. }
  846. return(rtrn);
  847. }
  848. /*******************************************************************************
  849. END OF FILE
  850. *******************************************************************************/