1 /*   ncbimsg.h
2 * ===========================================================================
3 *
4 *                            PUBLIC DOMAIN NOTICE
5 *               National Center for Biotechnology Information
6 *
7 *  This software/database is a "United States Government Work" under the
8 *  terms of the United States Copyright Act.  It was written as part of
9 *  the author's official duties as a United States Government employee and
10 *  thus cannot be copyrighted.  This software/database is freely available
11 *  to the public for use. The National Library of Medicine and the U.S.
12 *  Government have not placed any restriction on its use or reproduction.
13 *
14 *  Although all reasonable efforts have been taken to ensure the accuracy
15 *  and reliability of the software and data, the NLM and the U.S.
16 *  Government do not and cannot warrant the performance or results that
17 *  may be obtained by using this software or data. The NLM and the U.S.
18 *  Government disclaim all warranties, express or implied, including
19 *  warranties of performance, merchantability or fitness for any particular
20 *  purpose.
21 *
22 *  Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name:  ncbimsg.h
27 *
28 * Author:  Gish, Kans, Ostell, Schuler
29 *
30 * Version Creation Date:   1/1/91
31 *
32 * $Revision: 6.0 $
33 *
34 * File Description:
35 *   	prototypes for message and alert handling
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 * Date     Name        Description of modification
40 * -------  ----------  -----------------------------------------------------
41 * 04-15-93 Schuler     Changed _cdecl to LIBCALL
42 * 05-28-93 Schuler     New function: SetMonitorHook()
43 * 06-09-93 Schuler     Added magic_value field to Monitor
44 * 01-13-94 Schuler     Added SetMsgHook and SetBeepHook
45 * 08-23-94 Schuler     Workaround for Win32 Beep conflict
46 *
47 * $Log: ncbimsg.h,v $
48 * Revision 6.0  1997/08/25 18:16:54  madden
49 * Revision changed to 6.0
50 *
51 * Revision 5.2  1996/12/03 21:48:33  vakatov
52 * Adopted for 32-bit MS-Windows DLLs
53 *
54  * Revision 5.1  1996/07/05  16:26:10  kans
55  * changed MonitorXXNew functions to MonitorXXXNewEx, with new hasCancelBtn
56  * parameter, defined old functions to call new ones with hasCancelBtn TRUE.
57  *
58  * Revision 5.0  1996/05/28  13:18:57  ostell
59  * Set to revision 5.0
60  *
61  * Revision 4.0  1995/07/26  13:46:50  ostell
62  * force revision to 4.0
63  *
64  * Revision 2.11  1995/06/05  18:28:32  kans
65  * *** empty log message ***
66  *
67  * Revision 2.10  1995/05/15  18:45:58  ostell
68  * added Log line
69  *
70 *
71 *
72 * ==========================================================================
73 */
74 
75 #ifndef _NCBIMSG_
76 #define _NCBIMSG_
77 
78 #include <ncbierr.h>
79 
80 #undef NLM_EXTERN
81 #ifdef NLM_IMPORT
82 #define NLM_EXTERN NLM_IMPORT
83 #else
84 #define NLM_EXTERN extern
85 #endif
86 
87 
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91 
92 /*************************************************************************\
93 |                                ALERTS                                   |
94 \*************************************************************************/
95 
96 
97 typedef enum MsgKey
98 {
99 	KEY_NONE =0,
100 	KEY_OK,
101 	KEY_OKC,
102 	KEY_ARI,
103 	KEY_YNC,
104 	KEY_YN,
105 	KEY_RC,
106 	KEY_other
107 }
108 MsgKey;
109 
110 #define MSG_OK   KEY_OK
111 #define MSG_OKC  KEY_OKC
112 #define MSG_ARI  KEY_ARI
113 #define MSG_YNC  KEY_YNC
114 #define MSG_YN   KEY_YN
115 #define MSG_RC   KEY_RC
116 #define MSG_ERROR   (KEY_other +1)
117 #define MSG_FATAL   (KEY_other +2)
118 #define MSG_POST    (KEY_other +3)
119 #define MSG_POSTERR (KEY_other +4)
120 
121 
122 /* Message response codes */
123 typedef enum MsgAnswser
124 {
125 	ANS_NONE,
126 	ANS_OK,
127 	ANS_CANCEL,
128 	ANS_ABORT,
129 	ANS_RETRY,
130 	ANS_IGNORE,
131 	ANS_YES,
132 	ANS_NO
133 }
134 MsgAnswer;
135 
136 NLM_EXTERN MsgAnswer CDECL Nlm_Message VPROTO((Nlm_Int2 keysev, const char *fmt, ...));
137 
138 NLM_EXTERN MsgAnswer CDECL   Nlm_MsgAlert VPROTO((MsgKey key, ErrSev sev,
139 		const char *caption, const char *fmt, ...));
140 NLM_EXTERN MsgAnswer LIBCALL Nlm_MsgAlertStr PROTO((MsgKey key, ErrSev sev,
141 		const char *caption, const char *message));
142 
143 typedef MsgAnswer (LIBCALLBACK *MessageHook) PROTO((MsgKey key, ErrSev sev,
144 		const char *caption, const char *message));
145 
146 NLM_EXTERN MessageHook LIBCALL Nlm_SetMessageHook PROTO((MessageHook hook));
147 
148 #define Message Nlm_Message
149 #define MsgAlert Nlm_MsgAlert
150 #define MsgAlertStr Nlm_MsgAlertStr
151 #define SetMessageHook Nlm_SetMessageHook
152 
153 /*************************************************************************\
154 |                                 BEEPS                                   |
155 \*************************************************************************/
156 
157 typedef void (LIBCALLBACK *BeepHook) PROTO((void));
158 
159 NLM_EXTERN void LIBCALL Nlm_Beep PROTO((void));
160 NLM_EXTERN BeepHook LIBCALL Nlm_SetBeepHook PROTO((BeepHook));
161 
162 /*** MsgBeep is the preferred alias because there is a Win32 API
163 	called Beep.  Beep is undefined prior to including windows.h
164 	in ncbiwin.h.  Also Beep is not defined here if already defined
165 	elsewhere (incase you include windows.h first) ***/
166 #define MsgBeep Nlm_Beep
167 #ifndef Beep
168 #define Beep Nlm_Beep
169 #endif
170 #define SetBeepHook Nlm_SetBeepHook
171 
172 /*************************************************************************\
173 |                            PROGRESS MONITORS                            |
174 \*************************************************************************/
175 /* Monitor type codes */
176 typedef enum _MonType_
177 {
178 	MonType_Int =1, MonType_Str
179 }
180 MonType;
181 
182 /* Monitor notification codes */
183 typedef enum _MonCode_
184 {
185 	MonCode_Create=1,
186 	MonCode_Destroy,
187 	MonCode_IntValue,
188 	MonCode_StrValue
189 }
190 MonCode;
191 
192 typedef struct _Monitor_
193 {
194 	MonType     type;
195 	const char *strTitle;
196 	long        intValue;
197 	const char *strValue;
198 	long        num1;
199 	long        num2;
200 	void       *extra;	/* hook function may put things here */
201 	int         cancel;
202 	int         magic_value;   /* check for invalid object */
203 	int         hasCancelBtn;
204 }
205 Nlm_Monitor, *Nlm_MonitorPtr;
206 
207 #define Monitor Nlm_Monitor
208 #define MonitorPtr Nlm_MonitorPtr
209 
210 typedef int (LIBCALLBACK *Nlm_MonitorHook) PROTO((Nlm_MonitorPtr pMon, MonCode code));
211 #define MonitorHook Nlm_MonitorHook
212 
213 NLM_EXTERN MonitorPtr LIBCALL Nlm_MonitorIntNewEx PROTO((Nlm_CharPtr title, Nlm_Int4 n1, Nlm_Int4 n2, Nlm_Boolean hasCancelBtn));
214 NLM_EXTERN MonitorPtr LIBCALL Nlm_MonitorStrNewEx PROTO((Nlm_CharPtr title, Nlm_Int2 len, Nlm_Boolean hasCancelBtn));
215 NLM_EXTERN Nlm_Boolean LIBCALL Nlm_MonitorStrValue PROTO((MonitorPtr mon, Nlm_CharPtr sval));
216 NLM_EXTERN Nlm_Boolean LIBCALL Nlm_MonitorIntValue PROTO((MonitorPtr mon, Nlm_Int4 ival));
217 NLM_EXTERN MonitorPtr LIBCALL Nlm_MonitorFree PROTO((MonitorPtr mon));
218 NLM_EXTERN MonitorHook LIBCALL Nlm_SetMonitorHook PROTO((MonitorHook hook));
219 
220 #define MonitorIntNewEx Nlm_MonitorIntNewEx
221 #define MonitorStrNewEx Nlm_MonitorStrNewEx
222 #define MonitorStrValue Nlm_MonitorStrValue
223 #define MonitorIntValue Nlm_MonitorIntValue
224 #define MonitorFree Nlm_MonitorFree
225 #define SetMonitorHook Nlm_SetMonitorHook
226 
227 #define MonitorIntNew(a,b,c) Nlm_MonitorIntNewEx(a, b, c, TRUE)
228 #define Nlm_MonitorIntNew(a,b,c) Nlm_MonitorIntNewEx(a, b, c, TRUE)
229 #define MonitorStrNew(a,b) Nlm_MonitorStrNewEx(a, b, TRUE)
230 #define Nlm_MonitorStrNew(a,b) Nlm_MonitorStrNewEx(a, b, TRUE)
231 
232 /*****************************************************************************
233 *
234 *   Default Monitor
235 *
236 *****************************************************************************/
237 typedef Nlm_Boolean (LIBCALLBACK * Nlm_ProgMonFunc) PROTO((Nlm_VoidPtr data, Nlm_CharPtr str));
238 
239 NLM_EXTERN Nlm_Boolean LIBCALL Nlm_ProgMon PROTO((Nlm_CharPtr str));
240 NLM_EXTERN Nlm_Boolean LIBCALL Nlm_SetProgMon PROTO((Nlm_ProgMonFunc func, Nlm_VoidPtr data));
241 NLM_EXTERN Nlm_Boolean LIBCALLBACK Nlm_StdProgMon PROTO((Nlm_VoidPtr data, Nlm_CharPtr str));
242 
243 #define ProgMonFunc Nlm_ProgMonFunc
244 #define ProgMon Nlm_ProgMon
245 #define SetProgMon Nlm_SetProgMon
246 #define StdProgMon Nlm_StdProgMon
247 
248 #ifdef __cplusplus
249 }
250 #endif
251 
252 
253 #undef NLM_EXTERN
254 #ifdef NLM_EXPORT
255 #define NLM_EXTERN NLM_EXPORT
256 #else
257 #define NLM_EXTERN
258 #endif
259 #endif
260 
261