Don't redeclare forceUpdate() with the wrong prototype.
[oweals/cde.git] / cde / programs / dtudcexch / udcexc.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: udcexc.c /main/4 1996/09/02 18:50:32 cde-fuj $ */
24 /*
25  *  (c) Copyright 1995 FUJITSU LIMITED
26  *  This is source code modified by FUJITSU LIMITED under the Joint
27  *  Development Agreement for the CDEnext PST.
28  *  This is unpublished proprietary source code of FUJITSU LIMITED
29  */
30
31 #include "excutil.h"
32 #include "xoakufont.h"
33 #include "selectxlfd.h"
34 #include <locale.h>
35 #include <Xm/RowColumn.h>
36 #include <Xm/ToggleB.h>
37 #include <Xm/MessageB.h>
38 #include <Xm/MainW.h>
39 void callexpCB();
40 void callimpCB();
41 void exitCB();
42 void helpCB();
43 void udcexp();
44 void udcimp();
45
46 #define ERROR_1 errmsg_org[fal_utyerrno & 0xff]
47 /*#define ERROR_1 fal_errmsg_org[fal_utyerrno & 0xff]*/
48 /*#define ERROR_2 fal_errmsg_func[fal_utyerrno >>8]*/
49
50 Widget toplevel, mainw;
51
52 Exc_data *ed = NULL;
53 ListData        *ld = NULL;
54 char *maintitle;
55 /*char *terminatemsg = "Do you want to terminate dtudcexch";*/
56
57 /*
58  * Error messages(by origin)
59  * fal_errmsg_org
60  */
61 char    *errmsg_org[0xff];
62
63 Rsrc resource ;
64
65 #define Rchar(name, class, member,def){ \
66         name, class, XtRString, sizeof(char *), \
67         XtOffsetOf(Rsrc, member), XtRString, (XtPointer)def }
68
69 Widget excCreateRadioButton(Widget parent, String name, String label,
70                             XtCallbackProc callback_func,
71                             XtPointer client_data)
72 {
73     Widget      widget;
74     XmString    xms;
75
76     widget = XtVaCreateManagedWidget(name,
77                                      xmToggleButtonWidgetClass, parent,
78                                      XmNindicatorType, XmONE_OF_MANY,
79                                      NULL);
80     XtAddCallback(widget, XmNvalueChangedCallback,
81                   (XtCallbackProc) callback_func,
82                   (XtPointer) client_data);
83
84     xms = XmStringCreateLocalized(label);
85     XtVaSetValues(widget,
86                   XmNlabelString, xms,
87                   NULL);
88
89     XmStringFree(xms);
90
91     return (widget);
92 }    
93
94 int main(int argc, char * argv[])
95 {
96     XtAppContext        app_context;
97     Widget              row, expfunc, impfunc, exit/*, help*/;
98     Arg                 args[20];
99     Cardinal            n;
100     static char         *explabel;
101     static char         *implabel;
102     static char         *exitlabel;
103 /*    static char               helplabel[] = "Help";*/
104 /*    char                msg1[] = "Failed in the start of dtudcexch";*/
105     char        err[128];
106     int                 ans;
107
108     int mask = FAL_FONT_MASK_DEFINED | FAL_FONT_MASK_UNDEFINED;
109     FalFontData key;
110     FalFontDataList *fontlist;
111
112 /* appinitialize */
113     XtSetLanguageProc(NULL,NULL,NULL);
114     _DtEnvControl(0);
115     n = 0;
116     toplevel = XtAppInitialize(&app_context, "UDCexchange",
117                                (XrmOptionDescList) NULL,
118                                0, (int *) &argc, argv, (String *) NULL,
119                                args, n);
120
121     maintitle = GETMESSAGE(8, 2, "UDC data exchange utitlity");
122
123     errmsg_org[0] = GETMESSAGE(8, 4, "Fatal error occurred.");
124     errmsg_org[1] = GETMESSAGE(8, 6, "Cannot open the font file.");
125     errmsg_org[2] = GETMESSAGE(8, 8, "Cannot read the font file.");
126     errmsg_org[3] = GETMESSAGE(8, 10, "There is no more memory.");
127     errmsg_org[4] = GETMESSAGE(8, 12, "Fatal error occurred.");
128     errmsg_org[5] = GETMESSAGE(8, 14, "The specified font file does not exist.");
129     errmsg_org[6] = GETMESSAGE(8, 16, "This font is not a pcf or snf font.");
130     errmsg_org[7] = GETMESSAGE(8, 18, "Cannot open fonts.list file.");
131     errmsg_org[8] = GETMESSAGE(8, 20, "The format of fonts.list file is illegal.");
132     errmsg_org[9] = GETMESSAGE(8, 22, "The descriptions of the fonts.list file are incorrect.");
133     errmsg_org[10] = GETMESSAGE(8, 24, "The format of fonts.list file is illegal.");
134     errmsg_org[11] = GETMESSAGE(8, 26, "Cannot open fonts.dir file.");
135     errmsg_org[12] = GETMESSAGE(8, 28, "Cannot read fonts.dir file.");
136     errmsg_org[13] = GETMESSAGE(8, 30, "Cannot read font properties.");
137     errmsg_org[14] = GETMESSAGE(8, 32, "Cannot get FONT property.");
138     errmsg_org[15] = GETMESSAGE(8, 34, "Cannot get FAMILY_NAME property.");
139     errmsg_org[16] = GETMESSAGE(8, 36, "This font file is already opened by other application.");
140     errmsg_org[17] = GETMESSAGE(8, 38, "Cannot lock font file.");
141     errmsg_org[18] = GETMESSAGE(8, 40, "Cannot unlock font file.");
142     errmsg_org[19] = GETMESSAGE(8, 42, "Cannot get lock information from the font file.");
143     errmsg_org[20] = GETMESSAGE(8, 44, "Cannot find the specified font file.");
144     errmsg_org[21] = GETMESSAGE(8, 46, "Cannot read NLS database.");
145     errmsg_org[22] = GETMESSAGE(8, 48, "Cannot get charset names from NLS database.");
146     errmsg_org[23] = GETMESSAGE(8, 50, "Charset name not defined in NLS database.");
147     errmsg_org[24] = GETMESSAGE(8, 52, "The specified font has not been opened.");
148     errmsg_org[25] = GETMESSAGE(8, 54, "Fatal error occurred.");
149
150     resource.xlfd_label = GETMESSAGE(8, 56, "XLFD name          :" ),
151     resource.copy_xlfd_label = GETMESSAGE(8, 58, "Original font (XLFD name)  :");
152     resource.code_label = GETMESSAGE(8, 60, "UDC code area      :");
153     resource.style_label = GETMESSAGE(8, 62, "Style              :");
154     resource.size_label = GETMESSAGE(8, 64, "Size (letter size) :");
155     resource.exec_label = GETMESSAGE(8, 66, "Open");
156     resource.quit_label = GETMESSAGE(8, 68, "Cancel");
157     resource.ok_label = GETMESSAGE(8, 70, "OK");
158     resource.cancel_label = GETMESSAGE(8, 72, "cancel");
159     resource.copy_orgin = GETMESSAGE(8, 74, "Copy orgin code(hex)  :");
160     resource.copy_target = GETMESSAGE(8, 76, "Copy target code(hex) :");
161     resource.copy_label = GETMESSAGE(8, 78, "Copy");
162     resource.overlay_label = GETMESSAGE(8, 80, "Overlay");
163
164     explabel = GETMESSAGE(8, 82, "export function");
165     implabel = GETMESSAGE(8, 84, "import function");
166     exitlabel = GETMESSAGE(8, 86, "Cancel");
167
168 /* initialize ed */
169     if ((ed = (Exc_data *) malloc(sizeof(Exc_data))) == NULL) {
170         excerror(ed, EXCERRMALLOC, "main", "exit");
171     }
172     memset(ed,0x00,sizeof(Exc_data));
173
174     ed->app = app_context;
175     ed->toplevel = toplevel;
176
177     if (FalGetFontList(&key, mask, &fontlist) == FAL_ERROR) {
178         fprintf( stderr, "GetFontList Err\n" );
179         sprintf(err, "%s", ERROR_1);
180         AskUser(ed->toplevel, ed, err, &ans, "error");
181 /*      AskUser(ed->toplevel, ed, msg1, &ans, "error");*/
182         excexit(ed);
183     }
184     FalFreeFontList(fontlist);
185
186
187 /* make main window */
188     n = 0;
189     XtSetArg( args[n], XmNautoUnmanage, False ) ; n++ ;
190     XtSetArg(args[n], XmNtitle, maintitle); n++;
191     mainw = XmCreateTemplateDialog(toplevel, "mainw", args, n);
192
193     row = XtVaCreateManagedWidget("row", xmRowColumnWidgetClass, mainw,
194                                   XmNradioBehavior, True,
195                                   XmNradioAlwaysOne, True,
196                                   NULL);
197     expfunc = excCreateRadioButton(row, "expfunc", explabel,
198                                    (XtCallbackProc) callexpCB, (XtPointer) ed);
199
200     impfunc = excCreateRadioButton(row, "impfunc", implabel,
201                                    (XtCallbackProc) callimpCB, (XtPointer) ed);
202
203     exit = excCreatePushButton(mainw, "exit", exitlabel,
204                                (XtCallbackProc) exitCB, (XtPointer) ed);
205
206 /*    help = excCreatePushButton(mainw, "help", helplabel,
207                                (XtCallbackProc) helpCB, (XtPointer) ed);
208 */
209     XtVaSetValues(mainw,
210                   XmNmessageWindow, exit,
211                   NULL);
212
213     XtManageChild(mainw);
214     
215 /*    XtRealizeWidget(toplevel);*/
216
217     XtAppMainLoop(app_context);
218 }
219
220 void callexpCB(Widget widget, Exc_data * ed, XtPointer call_data)
221 {
222     XtUnmanageChild(mainw);
223     udcexp(ed);
224 }
225 void callimpCB(Widget widget, Exc_data * ed, XtPointer call_data)
226 {
227     XtUnmanageChild(mainw);
228     udcimp(ed);
229 }
230 void exitCB(Widget widget, Exc_data * ed, XtPointer call_data)
231 {
232     excexit(ed);
233 }
234 /*void helpCB(Widget widget, Exc_data * ed, XtPointer call_data)
235 {
236 }*/