Link with C++ linker
[oweals/cde.git] / cde / programs / dticon / newIconDialog.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $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 *******************************************************************************/
35
36 #include <stdio.h>
37 #include <Xm/Xm.h>
38 #include <Xm/DialogS.h>
39 #include <Xm/MenuShell.h>
40 #include <Xm/MwmUtil.h>
41
42 #include <Xm/TextF.h>
43 #include <Xm/LabelG.h>
44 #include <Xm/SeparatoG.h>
45 #include <Xm/PushBG.h>
46 #include <Xm/Form.h>
47
48 #include <Dt/DialogBox.h>
49
50 #include "main.h"
51 #include "externals.h"
52
53 /*******************************************************************************
54     Includes, Defines, and Global variables from the Declarations Editor:
55 *******************************************************************************/
56
57 static  Widget  newSeparator;
58 static  Widget  newWidthLabel;
59 static  Widget  newHeightLabel;
60
61 Widget  newIconDialog;
62 Widget  newWidthText;
63 Widget  newHeightText;
64
65 extern Widget  editMenu_deleteHS_pb;
66 /*******************************************************************************
67     Forward declarations of functions that are defined later in this file.
68 *******************************************************************************/
69
70 Widget  create_newIconDialog();
71
72 /*******************************************************************************
73     The following are callback functions.
74 *******************************************************************************/
75
76 /************************************************************************
77  *   ButtonCB()
78  *
79  ************************************************************************/
80 static void
81 ButtonCB(
82         Widget w,
83         XtPointer client_data,
84         XtPointer call_data )
85 {
86     DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *)call_data;
87
88     switch (cb->button_position)
89     {
90       case 1:                    /* OK button */
91              Process_Size_OK();
92           break;
93
94       case 2:                    /* CANCEL button */
95           Process_Size_Cancel();
96           break;
97
98       case 3:                    /* HELP button */
99           XtCallCallbacks(w, XmNhelpCallback, NULL);
100           break;
101
102       default:
103           break;
104     }
105 }
106
107
108 /*******************************************************************************
109     The 'build_' function creates all the widgets
110     using the resource values specified in the Property Editor.
111 *******************************************************************************/
112
113 static Widget
114 build_newIconDialog( void )
115 {
116     XmString    tmpXmStrings[3];
117     Widget      workForm;
118     Arg         args[10];
119     int         n;
120
121
122     /* create the dialog box with shell */
123
124     tmpXmStrings[0] = GETXMSTR(4,6, "OK");
125     tmpXmStrings[1] = GETXMSTR(4,8, "Cancel");
126     tmpXmStrings[2] = GETXMSTR(4,10, "Help");
127
128     n = 0;
129     XtSetArg (args[n], XmNbuttonCount, 3);                                 n++;
130     XtSetArg (args[n], XmNbuttonLabelStrings, tmpXmStrings);               n++;
131     newIconDialog = __DtCreateDialogBoxDialog (mainWindow, "newIconDialog",
132                                               args, n);
133
134     /* free compound strings now */
135     XmStringFree (tmpXmStrings[0]);
136     XmStringFree (tmpXmStrings[1]);
137     XmStringFree (tmpXmStrings[2]);
138
139     XtAddCallback(newIconDialog, XmNcallback, ButtonCB, NULL);
140
141     n = 0;
142     workForm = _DtDialogBoxGetButton(newIconDialog, 2);
143     XtSetArg(args[n], XmNcancelButton, workForm);                          n++;
144     XtSetValues (newIconDialog, args, n);
145
146     n = 0;
147     XtSetArg (args[n], XmNtitle, GETSTR(4,4, "Icon Editor - Resize"));     n++;
148     XtSetArg (args[n], XmNuseAsyncGeometry, True);                         n++;
149     XtSetArg (args[n], XmNmwmInputMode,MWM_INPUT_PRIMARY_APPLICATION_MODAL);n++;
150     XtSetValues (XtParent(newIconDialog), args, n);
151
152
153     /* create form with width/height to go in dialog box as work area */
154
155     workForm = XtVaCreateManagedWidget( "newIconForm",
156                 xmFormWidgetClass, newIconDialog,
157                 XmNchildType, XmWORK_AREA,
158                 XmNallowOverlap, False,
159                 NULL );
160
161     newWidthText = XtVaCreateManagedWidget( "newWidthText",
162                 xmTextFieldWidgetClass, workForm,
163                 XmNtopOffset, 5,
164                 XmNtopAttachment, XmATTACH_FORM,
165                 XmNrightOffset, 5,
166                 XmNrightAttachment, XmATTACH_FORM,
167                 NULL );
168
169     tmpXmStrings[0] = GETXMSTR(4,12, "New Width:");
170     newWidthLabel = XtVaCreateManagedWidget( "newWidthLabel",
171                 xmLabelGadgetClass, workForm,
172                 XmNalignment, XmALIGNMENT_END,
173                 XmNlabelString, tmpXmStrings[0],
174                 XmNtopOffset, 5,
175                 XmNtopAttachment, XmATTACH_FORM,
176                 XmNrightWidget, newWidthText,
177                 XmNrightAttachment, XmATTACH_WIDGET,
178                 XmNleftOffset, 5,
179                 XmNleftAttachment, XmATTACH_FORM,
180                 NULL );
181     XmStringFree(tmpXmStrings[0]);
182
183     newHeightText = XtVaCreateManagedWidget( "newHeightText",
184                 xmTextFieldWidgetClass, workForm,
185                 XmNtopWidget, newWidthText,
186                 XmNtopAttachment, XmATTACH_WIDGET,
187                 XmNrightOffset, 5,
188                 XmNrightAttachment, XmATTACH_FORM,
189                 XmNbottomOffset, 5,
190                 XmNbottomAttachment, XmATTACH_FORM,
191                 NULL );
192
193     tmpXmStrings[0] = GETXMSTR(4,14, "New Height:");
194     newHeightLabel = XtVaCreateManagedWidget( "newHeightLabel",
195                 xmLabelGadgetClass, workForm,
196                 XmNalignment, XmALIGNMENT_END,
197                 XmNlabelString, tmpXmStrings[0],
198                 XmNtopWidget, newWidthLabel,
199                 XmNtopAttachment, XmATTACH_WIDGET,
200                 XmNrightWidget, newHeightText,
201                 XmNrightAttachment, XmATTACH_WIDGET,
202                 XmNbottomOffset, 5,
203                 XmNbottomAttachment, XmATTACH_FORM,
204                 XmNleftOffset, 5,
205                 XmNleftAttachment, XmATTACH_FORM,
206                 NULL );
207     XmStringFree(tmpXmStrings[0]);
208
209     return ( newIconDialog );
210 }
211
212 /*******************************************************************************
213     The following is the 'Interface function' which is the
214     external entry point for creating this interface.
215     This function should be called from your application or from
216     a callback function.
217 *******************************************************************************/
218
219 Widget
220 create_newIconDialog( void )
221 {
222     Widget                  rtrn;
223
224     rtrn = build_newIconDialog();
225
226     return(rtrn);
227 }
228
229
230 /*******************************************************************************
231     END OF FILE
232 *******************************************************************************/
233