Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / DtMrm / DtMrm.c
1 /*
2  *                   Common Desktop Environment
3  *
4  * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
5  * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
6  * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
7  * (c) Copyright 1993, 1994, 1995 Novell, Inc.
8  * (c) Copyright 1995 Digital Equipment Corp.
9  * (c) Copyright 1995 Fujitsu Limited
10  * (c) Copyright 1995 Hitachi, Ltd.
11  *                                                                 
12  *
13  *                   RESTRICTED RIGHTS LEGEND                              
14  *
15  * Use, duplication, or disclosure by the U.S. Government is subject to
16  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
17  * Technical Data and Computer Software clause in DFARS 252.227-7013.  Rights
18  * for non-DOD U.S. Government Departments and Agencies are as set forth in
19  * FAR 52.227-19(c)(1,2).
20  * 
21  * Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A.
22  * International Business Machines Corp., Route 100, Somers, NY 10589 U.S.A. 
23  * Sun Microsystems, Inc., 2550 Garcia Avenue, Mountain View, CA 94043 U.S.A.
24  * Novell, Inc., 190 River Road, Summit, NJ 07901 U.S.A.
25  * Digital Equipment Corp., 111 Powdermill Road, Maynard, MA 01754, U.S.A.
26  * Fujitsu Limited, 1015, Kamikodanaka Nakahara-Ku, Kawasaki 211, Japan
27  * Hitachi, Ltd., 6, Kanda Surugadai 4-Chome, Chiyoda-ku, Tokyo 101, Japan
28  */
29 /*                                                                      *
30  * (c) Copyright 1996 Hewlett-Packard Company                           *
31  * (c) Copyright 1996 International Business Machines Corp.             *
32  * (c) Copyright 1996 Sun Microsystems, Inc.                            *
33  * (c) Copyright 1996 Novell, Inc.                                      *
34  * (c) Copyright 1989, 1990, 1996 Digital Equipment Corporation.        *
35  * (c) Copyright 1996 FUJITSU LIMITED.                                  *
36  * (c) Copyright 1996 Hitachi.                                          *
37  */
38 #ifdef REV_INFO
39 #ifndef lint
40 static char rcsid[] = "$TOG: DtMrm.c /main/4 1999/10/14 13:35:44 mgreess $"
41 #endif
42 #endif
43
44 /*
45  *++
46  *  FACILITY:
47  *
48  *      UIL Resource Manager (URM):
49  *
50  *  ABSTRACT:
51  *
52  *      This contains only the top-level routine DtMrmIntialize. It can be 
53  *      modified as needed to add or remove widgets being initialized for
54  *      URM facilities. This routine is normally accessible to
55  *      and used by an application at runtime to access URM facilities.
56  *
57  *--
58  */
59
60
61 /*
62  *
63  *  INCLUDE FILES
64  *
65  */
66 #if defined(__hpux)
67 #include <sys/param.h>
68 #endif
69
70 #include <X11/IntrinsicP.h>
71 #include <Xm/Xm.h>
72 #include <Mrm/MrmPublic.h>
73
74 #include <Dt/Editor.h>
75 #include <Dt/EditorP.h>
76 #include <Dt/Help.h>
77 #include <Dt/HelpP.h>
78 #include <Dt/HelpDialog.h>
79 #include <Dt/HelpDialogP.h>
80 #include <Dt/HelpQuickD.h>
81 #include <Dt/HelpQuickDP.h>
82 #include <Dt/MenuButton.h>
83 #include <Dt/MenuButtonP.h>
84 #include <Dt/Mrm.h>
85 #include <Dt/Print.h>
86 #include <Dt/PrintSetupBP.h>
87 #include <Dt/PrintSetupBP.h>
88 #include <Dt/Term.h>
89 /* work around conflict with <Xm/TextP.h> */
90 #ifdef PreUnder
91 #undef PreUnder
92 #endif
93 #include <Dt/TermP.h>
94
95 /********    Conditionally defined macros for thread_safe DtTerm ******/
96 #ifdef XTHREADS
97 #define _MrmProcessLock() XtProcessLock()
98 #define _MrmProcessUnlock() XtProcessUnlock()
99 #else /* XTHREADS */
100 #define _MrmProcessLock()
101 #define _MrmProcessUnlock()
102 #endif /* XTHREADS */
103
104 /*
105  *
106  *  TABLE OF CONTENTS
107  *
108  *      DtMrmInitialize                 Initialize URM internals before use
109  *
110  */
111
112 /*
113  * The following flag is set to indicate successful URM initialization
114  */
115 static  Boolean urm__initialize_complete = FALSE;
116
117 \f
118 void DtMrmInitialize ()
119
120 /*
121  *++
122  *  PROCEDURE DESCRIPTION:
123  *
124  *      DtMrmInitialize must be called in order to prepare an application to
125  *      use URM widget fetching facilities for CDE Dt widgets.  It is 
126  *      analogous to the MrmInitialize routine for Motif widgets.
127  *
128  *      DtMrmInitialize initializes the internal data
129  *      structures (creating the mapping from class codes to the creation
130  *      routine for each builtin widget class) which URM needs in order to 
131  *      successfully perform type conversion on arguments, and successfully 
132  *      access widget creation facilities. DtMrmInitialize must be called before
133  *      any widgets are created, whether by URM's fetch mechanisms or directly
134  *      by the application. It may be called before or after XtInitialize, and
135  *      multiple calls after the first one are benign (no-ops).
136  *
137  *  FORMAL PARAMETERS:
138  *
139  *  IMPLICIT INPUTS:
140  *
141  *  IMPLICIT OUTPUTS:
142  *
143  *  FUNCTION VALUE:
144  *
145  *  SIDE EFFECTS:
146  *
147  *--
148  */
149
150 {
151     _MrmProcessLock();
152     /*
153      * Initialize only once
154      */
155     if (urm__initialize_complete) 
156     {
157         _MrmProcessUnlock();
158         return;
159     }
160  
161     /*
162      * Initialize the class descriptors for all the known widgets.
163      */
164     MrmRegisterClass(
165                 0, NULL,
166                 "DtCreateEditor", DtCreateEditor,
167                 (WidgetClass) &dtEditorClassRec
168                 );
169
170     MrmRegisterClass(
171                 0, NULL,
172                 "DtCreateHelpDialog", DtCreateHelpDialog,
173                 (WidgetClass) &dtHelpDialogWidgetClassRec
174                 );
175
176     MrmRegisterClass(
177                 0, NULL,
178                 "DtCreateHelpQuickDialog", DtCreateHelpQuickDialog,
179                 (WidgetClass) &dtHelpQuickDialogWidgetClassRec
180                 );
181
182     MrmRegisterClass(
183                 0, NULL,
184                 "DtCreateMenuButton", DtCreateMenuButton,
185                 (WidgetClass) &dtMenuButtonClassRec
186                 );
187
188     MrmRegisterClass(
189                 0, NULL,
190                 "DtCreatePrintSetupBox", DtCreatePrintSetupBox,
191                 (WidgetClass) &dtPrintSetupBoxClassRec
192                 );
193
194     MrmRegisterClass(
195                 0, NULL,
196                 "DtCreatePrintSetupDialog", DtCreatePrintSetupDialog,
197                 (WidgetClass) &dtPrintSetupBoxClassRec
198                 );
199
200     MrmRegisterClass(
201                 0, NULL,
202                 "DtCreateTerm", DtCreateTerm,
203                 (WidgetClass) &dtTermClassRec
204                 );
205
206     /*
207      * Initialization complete
208      */
209     urm__initialize_complete = TRUE;
210     _MrmProcessUnlock();
211     return;
212 }