newIconDialog.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. /* $XConsortium: newIconDialog.c /main/4 1995/11/02 14:06:08 rswiston $ */
  24. /*********************************************************************
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  26. * (c) Copyright 1993, 1994 International Business Machines Corp.
  27. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  28. * (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  29. * Novell, Inc.
  30. **********************************************************************/
  31. /*******************************************************************************
  32. newIconDialog.c
  33. *******************************************************************************/
  34. #include <stdio.h>
  35. #include <Xm/Xm.h>
  36. #include <Xm/DialogS.h>
  37. #include <Xm/MenuShell.h>
  38. #include <Xm/MwmUtil.h>
  39. #include <Xm/TextF.h>
  40. #include <Xm/LabelG.h>
  41. #include <Xm/SeparatoG.h>
  42. #include <Xm/PushBG.h>
  43. #include <Xm/Form.h>
  44. #include <Dt/DialogBox.h>
  45. #include "main.h"
  46. #include "externals.h"
  47. #include "process.h"
  48. /*******************************************************************************
  49. Includes, Defines, and Global variables from the Declarations Editor:
  50. *******************************************************************************/
  51. static Widget newSeparator;
  52. static Widget newWidthLabel;
  53. static Widget newHeightLabel;
  54. Widget newIconDialog;
  55. Widget newWidthText;
  56. Widget newHeightText;
  57. extern Widget editMenu_deleteHS_pb;
  58. /*******************************************************************************
  59. Forward declarations of functions that are defined later in this file.
  60. *******************************************************************************/
  61. Widget create_newIconDialog();
  62. /*******************************************************************************
  63. The following are callback functions.
  64. *******************************************************************************/
  65. /************************************************************************
  66. * ButtonCB()
  67. *
  68. ************************************************************************/
  69. static void
  70. ButtonCB(
  71. Widget w,
  72. XtPointer client_data,
  73. XtPointer call_data )
  74. {
  75. DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *)call_data;
  76. switch (cb->button_position)
  77. {
  78. case 1: /* OK button */
  79. Process_Size_OK();
  80. break;
  81. case 2: /* CANCEL button */
  82. Process_Size_Cancel();
  83. break;
  84. case 3: /* HELP button */
  85. XtCallCallbacks(w, XmNhelpCallback, NULL);
  86. break;
  87. default:
  88. break;
  89. }
  90. }
  91. /*******************************************************************************
  92. The 'build_' function creates all the widgets
  93. using the resource values specified in the Property Editor.
  94. *******************************************************************************/
  95. static Widget
  96. build_newIconDialog( void )
  97. {
  98. XmString tmpXmStrings[3];
  99. Widget workForm;
  100. Arg args[10];
  101. int n;
  102. /* create the dialog box with shell */
  103. tmpXmStrings[0] = GETXMSTR(4,6, "OK");
  104. tmpXmStrings[1] = GETXMSTR(4,8, "Cancel");
  105. tmpXmStrings[2] = GETXMSTR(4,10, "Help");
  106. n = 0;
  107. XtSetArg (args[n], XmNbuttonCount, 3); n++;
  108. XtSetArg (args[n], XmNbuttonLabelStrings, tmpXmStrings); n++;
  109. newIconDialog = __DtCreateDialogBoxDialog (mainWindow, "newIconDialog",
  110. args, n);
  111. /* free compound strings now */
  112. XmStringFree (tmpXmStrings[0]);
  113. XmStringFree (tmpXmStrings[1]);
  114. XmStringFree (tmpXmStrings[2]);
  115. XtAddCallback(newIconDialog, XmNcallback, ButtonCB, NULL);
  116. n = 0;
  117. workForm = _DtDialogBoxGetButton(newIconDialog, 2);
  118. XtSetArg(args[n], XmNcancelButton, workForm); n++;
  119. XtSetValues (newIconDialog, args, n);
  120. n = 0;
  121. XtSetArg (args[n], XmNtitle, GETSTR(4,4, "Icon Editor - Resize")); n++;
  122. XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
  123. XtSetArg (args[n], XmNmwmInputMode,MWM_INPUT_PRIMARY_APPLICATION_MODAL);n++;
  124. XtSetValues (XtParent(newIconDialog), args, n);
  125. /* create form with width/height to go in dialog box as work area */
  126. workForm = XtVaCreateManagedWidget( "newIconForm",
  127. xmFormWidgetClass, newIconDialog,
  128. XmNchildType, XmWORK_AREA,
  129. XmNallowOverlap, False,
  130. NULL );
  131. newWidthText = XtVaCreateManagedWidget( "newWidthText",
  132. xmTextFieldWidgetClass, workForm,
  133. XmNtopOffset, 5,
  134. XmNtopAttachment, XmATTACH_FORM,
  135. XmNrightOffset, 5,
  136. XmNrightAttachment, XmATTACH_FORM,
  137. NULL );
  138. tmpXmStrings[0] = GETXMSTR(4,12, "New Width:");
  139. newWidthLabel = XtVaCreateManagedWidget( "newWidthLabel",
  140. xmLabelGadgetClass, workForm,
  141. XmNalignment, XmALIGNMENT_END,
  142. XmNlabelString, tmpXmStrings[0],
  143. XmNtopOffset, 5,
  144. XmNtopAttachment, XmATTACH_FORM,
  145. XmNrightWidget, newWidthText,
  146. XmNrightAttachment, XmATTACH_WIDGET,
  147. XmNleftOffset, 5,
  148. XmNleftAttachment, XmATTACH_FORM,
  149. NULL );
  150. XmStringFree(tmpXmStrings[0]);
  151. newHeightText = XtVaCreateManagedWidget( "newHeightText",
  152. xmTextFieldWidgetClass, workForm,
  153. XmNtopWidget, newWidthText,
  154. XmNtopAttachment, XmATTACH_WIDGET,
  155. XmNrightOffset, 5,
  156. XmNrightAttachment, XmATTACH_FORM,
  157. XmNbottomOffset, 5,
  158. XmNbottomAttachment, XmATTACH_FORM,
  159. NULL );
  160. tmpXmStrings[0] = GETXMSTR(4,14, "New Height:");
  161. newHeightLabel = XtVaCreateManagedWidget( "newHeightLabel",
  162. xmLabelGadgetClass, workForm,
  163. XmNalignment, XmALIGNMENT_END,
  164. XmNlabelString, tmpXmStrings[0],
  165. XmNtopWidget, newWidthLabel,
  166. XmNtopAttachment, XmATTACH_WIDGET,
  167. XmNrightWidget, newHeightText,
  168. XmNrightAttachment, XmATTACH_WIDGET,
  169. XmNbottomOffset, 5,
  170. XmNbottomAttachment, XmATTACH_FORM,
  171. XmNleftOffset, 5,
  172. XmNleftAttachment, XmATTACH_FORM,
  173. NULL );
  174. XmStringFree(tmpXmStrings[0]);
  175. return ( newIconDialog );
  176. }
  177. /*******************************************************************************
  178. The following is the 'Interface function' which is the
  179. external entry point for creating this interface.
  180. This function should be called from your application or from
  181. a callback function.
  182. *******************************************************************************/
  183. Widget
  184. create_newIconDialog( void )
  185. {
  186. Widget rtrn;
  187. rtrn = build_newIconDialog();
  188. return(rtrn);
  189. }
  190. /*******************************************************************************
  191. END OF FILE
  192. *******************************************************************************/