1 /* vibprmpt.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
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 do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: vibprmpt.c
27 *
28 * Author: Jonathan Kans
29 *
30 * Version Creation Date: 7/1/91
31 *
32 * $Revision: 6.3 $
33 *
34 * File Description:
35 * Vibrant prompt functions
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 * Date Name Description of modification
40 * ------- ---------- -----------------------------------------------------
41 *
42 *
43 * $Log: vibprmpt.c,v $
44 * Revision 6.3 2008/04/29 13:43:50 kans
45 * fixes for warnings caught by mingw cross-compiler
46 *
47 * Revision 6.2 2004/07/19 13:36:43 bollin
48 * replaced obsolete XmFontListCreate function to get rid of run-time warnings
49 *
50 * Revision 6.1 1997/11/26 21:30:33 vakatov
51 * Fixed errors and warnings issued by C and C++ (GNU and Sun) compilers
52 *
53 * Revision 6.0 1997/08/25 18:57:25 madden
54 * Revision changed to 6.0
55 *
56 * Revision 5.1 1997/01/29 16:41:22 kans
57 * using StringNCpy_0
58 *
59 * Revision 5.0 1996/05/28 13:45:08 ostell
60 * Set to revision 5.0
61 *
62 * Revision 4.2 1996/03/02 22:36:38 kans
63 * reduction of X traffic (DV)
64 *
65 * Revision 4.1 1996/02/13 17:24:07 kans
66 * accelerated set position prior to realization (Denis Vakatov)
67 *
68 * Revision 4.0 1995/07/26 13:51:04 ostell
69 * force revision to 4.0
70 *
71 * Revision 2.12 1995/05/17 15:15:14 kans
72 * added Log line
73 *
74 *
75 * ==========================================================================
76 */
77
78 #include <vibtypes.h>
79 #include <vibprocs.h>
80 #include <vibincld.h>
81
82 #ifdef WIN_MAC
83 #define Nlm_PromptTool Nlm_Handle
84 #endif
85
86 #ifdef WIN_MSWIN
87 #define Nlm_PromptTool HWND
88 #endif
89
90 #ifdef WIN_MOTIF
91 #define Nlm_PromptTool Widget
92 #endif
93
94 typedef struct Nlm_promptdata {
95 Nlm_PromptTool handle;
96 Nlm_FonT font;
97 Nlm_Int2 height;
98 Nlm_Char just;
99 } Nlm_PromptData;
100
101 typedef struct Nlm_promptrec {
102 Nlm_GraphicRec graphicR;
103 Nlm_PromptData prompt;
104 } Nlm_PromptRec, PNTR Nlm_PptPtr;
105
106 static Nlm_GphPrcsPtr gphprcsptr = NULL;
107
108 static Nlm_GphPrcsPtr promptProcs;
109 static Nlm_GphPrcsPtr staticPromptProcs;
110
111 static Nlm_PrompT recentPrompt = NULL;
112 static Nlm_PromptData recentPromptData;
113
Nlm_LoadPromptData(Nlm_PrompT p,Nlm_PromptTool hdl,Nlm_FonT fnt,Nlm_Int2 hgt,Nlm_Char jst)114 static void Nlm_LoadPromptData (Nlm_PrompT p, Nlm_PromptTool hdl,
115 Nlm_FonT fnt, Nlm_Int2 hgt,
116 Nlm_Char jst)
117
118 {
119 Nlm_PptPtr pp;
120 Nlm_PromptData PNTR pptr;
121
122 if (p != NULL) {
123 pp = (Nlm_PptPtr) Nlm_HandLock (p);
124 pptr = &(pp->prompt);
125 pptr->handle = hdl;
126 pptr->font = fnt;
127 pptr->height = hgt;
128 pptr->just = jst;
129 Nlm_HandUnlock (p);
130 recentPrompt = NULL;
131 }
132 }
133
Nlm_GetPromptData(Nlm_PrompT p,Nlm_PromptData * pdata)134 static void Nlm_GetPromptData (Nlm_PrompT p, Nlm_PromptData * pdata)
135
136 {
137 Nlm_PptPtr pp;
138
139 if (p != NULL && pdata != NULL) {
140 if (p == recentPrompt && NLM_RISKY) {
141 *pdata = recentPromptData;
142 } else {
143 pp = (Nlm_PptPtr) Nlm_HandLock (p);
144 *pdata = pp->prompt;
145 Nlm_HandUnlock (p);
146 recentPrompt = p;
147 recentPromptData = *pdata;
148 }
149 }
150 }
151
152 #ifdef WIN_MAC
Nlm_SetPromptData(Nlm_PrompT p,Nlm_PromptData * pdata)153 static void Nlm_SetPromptData (Nlm_PrompT p, Nlm_PromptData * pdata)
154 {
155 Nlm_PptPtr pp;
156
157 if (p != NULL && pdata != NULL) {
158 pp = (Nlm_PptPtr) Nlm_HandLock (p);
159 pp->prompt = *pdata;
160 Nlm_HandUnlock (p);
161 recentPrompt = p;
162 recentPromptData = *pdata;
163 }
164 }
165
Nlm_SetPromptHandle(Nlm_PrompT p,Nlm_PromptTool hdl)166 static void Nlm_SetPromptHandle (Nlm_PrompT p, Nlm_PromptTool hdl)
167 {
168 Nlm_PromptData pdata;
169
170 Nlm_GetPromptData (p, &pdata);
171 pdata.handle = hdl;
172 Nlm_SetPromptData (p, &pdata);
173 }
174 #endif
175
Nlm_GetPromptHandle(Nlm_PrompT p)176 static Nlm_PromptTool Nlm_GetPromptHandle (Nlm_PrompT p)
177
178 {
179 Nlm_PromptData pdata;
180
181 Nlm_GetPromptData (p, &pdata);
182 return pdata.handle;
183 }
184
185 #ifdef WIN_MAC
Nlm_DrawPrompt(Nlm_GraphiC p)186 static void Nlm_DrawPrompt (Nlm_GraphiC p)
187
188 {
189 Nlm_Boolean gray;
190 Nlm_PromptTool h;
191 Nlm_PromptData pd;
192 Nlm_RecT r;
193 Nlm_Char str [256];
194
195 if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
196 Nlm_GetPromptData ((Nlm_PrompT) p, &pd);
197 h = pd.handle;
198 if (h != NULL) {
199 if (pd.font != NULL) {
200 Nlm_SelectFont (pd.font);
201 }
202 Nlm_GetString (h, str, sizeof (str));
203 if (Nlm_StringLen (str) > 0) {
204 if (Nlm_Enabled (p) && Nlm_AllParentsEnabled (p)) {
205 gray = FALSE;
206 } else {
207 gray = TRUE;
208 }
209 Nlm_GetRect (p, &r);
210 Nlm_DrawString (&r, str, pd.just, gray);
211 }
212 Nlm_SelectFont (Nlm_systemFont);
213 }
214 }
215 }
216 #endif
217
Nlm_ShowPrompt(Nlm_GraphiC p,Nlm_Boolean setFlag,Nlm_Boolean savePort)218 static void Nlm_ShowPrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
219
220 {
221 Nlm_PromptTool h;
222 Nlm_WindoW tempPort;
223
224 if (setFlag) {
225 Nlm_SetVisible (p, TRUE);
226 }
227 if (Nlm_GetVisible (p) && Nlm_AllParentsButWindowVisible (p)) {
228 tempPort = Nlm_SavePortIfNeeded (p, savePort);
229 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
230 #ifdef WIN_MAC
231 Nlm_DoDraw (p);
232 #endif
233 #ifdef WIN_MSWIN
234 ShowWindow (h, SW_SHOW);
235 UpdateWindow (h);
236 #endif
237 #ifdef WIN_MOTIF
238 XtManageChild (h);
239 #endif
240 Nlm_RestorePort (tempPort);
241 }
242 }
243
Nlm_HidePrompt(Nlm_GraphiC p,Nlm_Boolean setFlag,Nlm_Boolean savePort)244 static void Nlm_HidePrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
245
246 {
247 Nlm_PromptTool h;
248 Nlm_WindoW tempPort;
249 #ifdef WIN_MAC
250 Nlm_RecT r;
251 #endif
252
253 if (setFlag) {
254 Nlm_SetVisible (p, FALSE);
255 }
256 tempPort = Nlm_SavePortIfNeeded (p, savePort);
257 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
258 #ifdef WIN_MAC
259 if (Nlm_GetAllParentsVisible (p)) {
260 Nlm_GetRect (p, &r);
261 Nlm_InsetRect (&r, -1, -1);
262 Nlm_EraseRect (&r);
263 Nlm_ValidRect (&r);
264 }
265 #endif
266 #ifdef WIN_MSWIN
267 ShowWindow (h, SW_HIDE);
268 UpdateWindow (h);
269 #endif
270 #ifdef WIN_MOTIF
271 XtUnmanageChild (h);
272 #endif
273 Nlm_RestorePort (tempPort);
274 }
275
Nlm_EnablePrompt(Nlm_GraphiC p,Nlm_Boolean setFlag,Nlm_Boolean savePort)276 static void Nlm_EnablePrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
277
278 {
279 Nlm_PromptTool h;
280 Nlm_WindoW tempPort;
281 #ifdef WIN_MAC
282 Nlm_RecT r;
283 #endif
284
285 if (setFlag) {
286 Nlm_SetEnabled (p, TRUE);
287 }
288 if (Nlm_GetEnabled (p) && Nlm_GetAllParentsEnabled (p)) {
289 tempPort = Nlm_SavePortIfNeeded (p, savePort);
290 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
291 #ifdef WIN_MAC
292 if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
293 if (h != NULL) {
294 Nlm_DrawPrompt (p);
295 } else {
296 Nlm_GetRect (p, &r);
297 Nlm_InvalRect (&r);
298 }
299 }
300 #endif
301 #ifdef WIN_MSWIN
302 EnableWindow (h, TRUE);
303 #endif
304 #ifdef WIN_MOTIF
305 XtVaSetValues (h, XmNsensitive, TRUE, NULL);
306 #endif
307 Nlm_RestorePort (tempPort);
308 }
309 }
310
Nlm_DisablePrompt(Nlm_GraphiC p,Nlm_Boolean setFlag,Nlm_Boolean savePort)311 static void Nlm_DisablePrompt (Nlm_GraphiC p, Nlm_Boolean setFlag, Nlm_Boolean savePort)
312
313 {
314 Nlm_PromptTool h;
315 Nlm_WindoW tempPort;
316 #ifdef WIN_MAC
317 Nlm_RecT r;
318 #endif
319
320 if (setFlag) {
321 Nlm_SetEnabled (p, FALSE);
322 }
323 tempPort = Nlm_SavePortIfNeeded (p, savePort);
324 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
325 #ifdef WIN_MAC
326 if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
327 if (h != NULL) {
328 Nlm_DrawPrompt (p);
329 } else {
330 Nlm_GetRect (p, &r);
331 Nlm_InvalRect (&r);
332 }
333 }
334 #endif
335 #ifdef WIN_MSWIN
336 EnableWindow (h, FALSE);
337 #endif
338 #ifdef WIN_MOTIF
339 XtVaSetValues (h, XmNsensitive, FALSE, NULL);
340 #endif
341 Nlm_RestorePort (tempPort);
342 }
343
Nlm_RemovePrompt(Nlm_GraphiC p,Nlm_Boolean savePort)344 static void Nlm_RemovePrompt (Nlm_GraphiC p, Nlm_Boolean savePort)
345
346 {
347 Nlm_GraphicData gdata;
348 Nlm_PromptTool h;
349 Nlm_WindoW tempPort;
350
351 tempPort = Nlm_SavePortIfNeeded (p, savePort);
352 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
353 if (h != NULL) {
354 #ifdef WIN_MAC
355 Nlm_HandFree (h);
356 #endif
357 #ifdef WIN_MSWIN
358 DestroyWindow (h);
359 #endif
360 #ifdef WIN_MOTIF
361 XtDestroyWidget (h);
362 #endif
363 }
364 Nlm_GetGraphicData (p, &gdata);
365 if (gdata.data != NULL && gdata.cleanup != NULL) {
366 gdata.cleanup ((Nlm_GraphiC) p, gdata.data);
367 }
368 Nlm_HandFree (p);
369 recentPrompt = NULL;
370 Nlm_RestorePort (tempPort);
371 }
372
Nlm_RemoveLinkedInPrompt(Nlm_GraphiC p,Nlm_Boolean savePort)373 static void Nlm_RemoveLinkedInPrompt (Nlm_GraphiC p, Nlm_Boolean savePort)
374
375 {
376 Nlm_PromptTool h;
377 Nlm_WindoW tempPort;
378
379 tempPort = Nlm_SavePortIfNeeded (p, savePort);
380 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
381 if (h != NULL) {
382 #ifdef WIN_MAC
383 Nlm_HandFree (h);
384 #endif
385 #ifdef WIN_MSWIN
386 DestroyWindow (h);
387 #endif
388 #ifdef WIN_MOTIF
389 XtDestroyWidget (h);
390 #endif
391 }
392 Nlm_RemoveLink (p);
393 recentPrompt = NULL;
394 Nlm_RestorePort (tempPort);
395 }
396
Nlm_SetPromptTitle(Nlm_GraphiC p,Nlm_Int2 item,Nlm_CharPtr title,Nlm_Boolean savePort)397 static void Nlm_SetPromptTitle (Nlm_GraphiC p, Nlm_Int2 item,
398 Nlm_CharPtr title, Nlm_Boolean savePort)
399
400 {
401 Nlm_PromptTool h;
402 Nlm_WindoW tempPort;
403 #ifdef WIN_MAC
404 Nlm_RecT r;
405 #endif
406 #ifdef WIN_MOTIF
407 XmString label;
408 #endif
409
410 tempPort = Nlm_SavePortIfNeeded (p, savePort);
411 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
412 #ifdef WIN_MAC
413 h = Nlm_SetString (h, title);
414 Nlm_SetPromptHandle ((Nlm_PrompT) p, h);
415 if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
416 if (h != NULL) {
417 Nlm_DrawPrompt (p);
418 } else {
419 Nlm_GetRect (p, &r);
420 Nlm_InvalRect (&r);
421 }
422 }
423 #endif
424 #ifdef WIN_MSWIN
425 if (h != NULL) {
426 SetWindowText (h, title);
427 if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
428 UpdateWindow (h);
429 }
430 }
431 #endif
432 #ifdef WIN_MOTIF
433 if (h != NULL) {
434 label = XmStringCreateSimple (title);
435 XtVaSetValues (h, XmNlabelString, label, NULL);
436 XmStringFree (label);
437 }
438 #endif
439 Nlm_RestorePort (tempPort);
440 }
441
Nlm_GetPromptTitle(Nlm_GraphiC p,Nlm_Int2 item,Nlm_CharPtr title,size_t maxsize)442 static void Nlm_GetPromptTitle (Nlm_GraphiC p, Nlm_Int2 item,
443 Nlm_CharPtr title, size_t maxsize)
444
445 {
446 Nlm_PromptTool h;
447 #ifdef WIN_MSWIN
448 Nlm_Char temp [256];
449 #endif
450 #ifdef WIN_MOTIF
451 XmString label;
452 char *text;
453 #endif
454
455 if (title != NULL) {
456 h = Nlm_GetPromptHandle ((Nlm_PrompT) p);
457 if (h != NULL) {
458 #ifdef WIN_MAC
459 Nlm_GetString (h, title, maxsize);
460 #endif
461 #ifdef WIN_MSWIN
462 GetWindowText (h, temp, sizeof (temp));
463 Nlm_StringNCpy_0 (title, temp, maxsize);
464 #endif
465 #ifdef WIN_MOTIF
466 XtVaGetValues (h, XmNlabelString, &label, NULL);
467 title [0] = '\0';
468 if (XmStringGetLtoR (label, XmSTRING_DEFAULT_CHARSET, &text)) {
469 Nlm_StringNCpy_0 (title, text, maxsize);
470 XtFree (text);
471 }
472 #endif
473 } else {
474 Nlm_StringNCpy_0 (title, "", maxsize);
475 }
476 }
477 }
478
479 #ifdef WIN_MAC
Nlm_InvalPrompt(Nlm_GraphiC p)480 static void Nlm_InvalPrompt (Nlm_GraphiC p)
481 {
482 Nlm_RecT r;
483 /*
484 #ifdef WIN_MSWIN
485 Nlm_RectTool rtool;
486 Nlm_WindowTool wptr;
487 #endif
488 */
489
490 if (Nlm_GetVisible (p) && Nlm_GetAllParentsVisible (p)) {
491 #ifdef WIN_MAC
492 Nlm_GetRect (p, &r);
493 Nlm_InsetRect (&r, -1, -1);
494 Nlm_InvalRect (&r);
495 #endif
496 /*
497 #ifdef WIN_MSWIN
498 wptr = Nlm_ParentWindowPtr (p);
499 Nlm_GetRect (p, &r);
500 r.top = r.bottom - 1;
501 r.bottom++;
502 Nlm_RecTToRectTool (&r, &rtool);
503 InvalidateRect (wptr, &rtool, TRUE);
504 Nlm_GetRect (p, &r);
505 r.left = r.right - 1;
506 r.right++;
507 Nlm_RecTToRectTool (&r, &rtool);
508 InvalidateRect (wptr, &rtool, TRUE);
509 #endif
510 */
511 }
512 }
513 #endif /* ndef WIN_MOTIF */
514
Nlm_SetPromptPosition(Nlm_GraphiC p,Nlm_RectPtr r,Nlm_Boolean savePort,Nlm_Boolean force)515 static void Nlm_SetPromptPosition (Nlm_GraphiC p, Nlm_RectPtr r,
516 Nlm_Boolean savePort, Nlm_Boolean force)
517 {
518 Nlm_Int2 delta;
519 Nlm_PromptTool h;
520 Nlm_Int2 height;
521 Nlm_Int2 limit;
522 Nlm_RecT oldRect;
523 Nlm_PromptData pdata;
524 Nlm_RecT rct;
525 Nlm_WindoW tempPort;
526
527 if (r == NULL) return;
528
529 if ( !Nlm_GetRealized( p ) )
530 {
531 Nlm_SetRect (p, r);
532 return;
533 }
534
535 Nlm_DoGetPosition (p, &oldRect);
536 if (!force && Nlm_EqualRect (r, &oldRect)) return;
537
538 tempPort = Nlm_SavePortIfNeeded (p, savePort);
539 Nlm_GetPromptData ((Nlm_PrompT) p, &pdata);
540 h = pdata.handle;
541 rct = *r;
542 limit = ABS (rct.bottom - rct.top);
543 height = pdata.height;
544 delta = limit - height;
545 if (delta > 0) {
546 rct.top += delta / 2;
547 rct.bottom = rct.top + height;
548 }
549
550 #ifdef WIN_MAC
551 Nlm_InvalPrompt (p);
552 Nlm_SetRect (p, r);
553 Nlm_InvalPrompt (p);
554 #endif
555 #ifdef WIN_MSWIN
556 Nlm_SetRect (p, r);
557 if (h != NULL) {
558 MoveWindow (h, rct.left, rct.top, rct.right - rct.left,
559 rct.bottom - rct.top, TRUE);
560 UpdateWindow (h);
561 }
562 #endif
563 #ifdef WIN_MOTIF
564 XtVaSetValues (h,
565 XmNx, (Position) rct.left,
566 XmNy, (Position) rct.top,
567 XmNwidth, (Dimension) (rct.right - rct.left),
568 XmNheight, (Dimension) (rct.bottom - rct.top),
569 NULL);
570 Nlm_SetRect (p, r);
571 #endif
572
573 Nlm_RestorePort (tempPort);
574 }
575
576
Nlm_GetPromptPosition(Nlm_GraphiC p,Nlm_RectPtr r)577 static void Nlm_GetPromptPosition (Nlm_GraphiC p, Nlm_RectPtr r)
578
579 {
580 if (r != NULL) {
581 Nlm_GetRect (p, r);
582 }
583 }
584
585
Nlm_NewPrompt(Nlm_PrompT p,Nlm_CharPtr title,Nlm_FonT font,Nlm_Char just)586 static void Nlm_NewPrompt (Nlm_PrompT p, Nlm_CharPtr title, Nlm_FonT font, Nlm_Char just)
587
588 {
589 Nlm_Int2 delta;
590 Nlm_PromptTool h;
591 Nlm_Int2 height;
592 Nlm_Int2 limit;
593 Nlm_Char local [128];
594 Nlm_RecT r;
595 Nlm_WindowTool wptr;
596 #ifdef WIN_MSWIN
597 Nlm_FntPtr fntptr;
598 Nlm_Int4 style;
599 #endif
600 #ifdef WIN_MOTIF
601 Nlm_FntPtr fntptr;
602 XmFontList fontlist;
603 XmString label;
604 Cardinal n;
605 Arg wargs [15];
606 XmFontListEntry font_entry;
607 #endif
608
609 local [0] = '\0';
610 Nlm_StringNCpy_0 (local, title, sizeof (local) - 1);
611 Nlm_GetRect ((Nlm_GraphiC) p, &r);
612 limit = ABS (r.bottom - r.top);
613 height = Nlm_LineHeight ();
614 delta = limit - height;
615 if (delta > 0) {
616 r.top += delta / 2;
617 r.bottom = r.top + height;
618 }
619 wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) p);
620
621 #ifdef WIN_MAC
622 h = Nlm_SetString (NULL, local);
623 #endif
624
625 #ifdef WIN_MSWIN
626 switch (just) {
627 case 'r':
628 style = SS_RIGHT;
629 break;
630 case 'l':
631 style = SS_LEFT;
632 break;
633 case 'c':
634 style = SS_CENTER;
635 break;
636 default:
637 style = SS_LEFT;
638 break;
639 }
640 h = CreateWindow ("Static", local, WS_CHILD | SS_NOPREFIX | style,
641 r.left, r.top, r.right - r.left,
642 r.bottom - r.top, wptr, 0,
643 Nlm_currentHInst, NULL);
644 if (font != NULL) {
645 fntptr = (Nlm_FntPtr) Nlm_HandLock (font);
646 if (fntptr != NULL && fntptr->handle != NULL) {
647 SetWindowFont (h, fntptr->handle, FALSE);
648 }
649 Nlm_HandUnlock (font);
650 }
651 #endif
652
653 #ifdef WIN_MOTIF
654 fontlist = NULL;
655 if (font != NULL) {
656 fntptr = (Nlm_FntPtr) Nlm_HandLock (font);
657 if (fntptr != NULL && fntptr->handle != NULL) {
658 font_entry = XmFontListEntryCreate (XmFONTLIST_DEFAULT_TAG,
659 XmFONT_IS_FONT,
660 fntptr->handle);
661 fontlist = XmFontListAppendEntry (fontlist, font_entry);
662 }
663 Nlm_HandUnlock (font);
664 }
665
666 n = 0;
667 label = XmStringCreateSimple (local[0] ? local : " ");
668 XtSetArg (wargs [n], XmNlabelString, label); n++;
669 XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
670 XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
671 XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left)); n++;
672 XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top)); n++;
673 XtSetArg (wargs [n], XmNmarginHeight, 0); n++;
674 XtSetArg (wargs [n], XmNmarginWidth, 0); n++;
675 XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
676 XtSetArg (wargs [n], XmNrecomputeSize, FALSE); n++;
677 XtSetArg (wargs [n], XmNfontList, fontlist); n++;
678 switch (just) {
679 case 'r':
680 XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_END); n++;
681 break;
682 case 'l':
683 XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
684 break;
685 case 'c':
686 XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_CENTER); n++;
687 break;
688 default:
689 XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
690 break;
691 }
692 h = XmCreateLabel (wptr, (String) "", wargs, n);
693 XmStringFree (label);
694 XtManageChild( h );
695
696 if (fontlist != NULL) {
697 XmFontListFree (fontlist);
698 }
699 #endif
700
701 Nlm_LoadPromptData (p, h, font, height, just);
702 }
703
704
Nlm_DependentPrompt(Nlm_GraphiC prnt,Nlm_RectPtr r,Nlm_CharPtr title,Nlm_FonT font,Nlm_Char just)705 extern Nlm_PrompT Nlm_DependentPrompt (Nlm_GraphiC prnt, Nlm_RectPtr r,
706 Nlm_CharPtr title, Nlm_FonT font,
707 Nlm_Char just)
708
709 {
710 Nlm_PrompT p;
711 Nlm_WindoW tempPort;
712
713 p = NULL;
714 if (prnt != NULL && r != NULL) {
715 tempPort = Nlm_SavePort (prnt);
716 if (font != NULL) {
717 Nlm_SelectFont (font);
718 } else {
719 Nlm_SelectFont (Nlm_systemFont);
720 }
721 p = (Nlm_PrompT) Nlm_HandNew (sizeof (Nlm_PromptRec));
722 if (p != NULL) {
723 Nlm_LoadGraphicData ((Nlm_GraphiC) p, NULL, (Nlm_GraphiC) prnt,
724 NULL, NULL, promptProcs, NULL, r, TRUE, FALSE, NULL, NULL);
725 if (Nlm_nextIdNumber < 32767) {
726 Nlm_nextIdNumber++;
727 }
728 Nlm_NewPrompt (p, title, font, just);
729 }
730 Nlm_SelectFont (Nlm_systemFont);
731 Nlm_RestorePort (tempPort);
732 }
733 return p;
734 }
735
Nlm_StaticPrompt(Nlm_GrouP prnt,Nlm_CharPtr title,Nlm_Int2 pixwidth,Nlm_Int2 pixheight,Nlm_FonT font,Nlm_Char just)736 extern Nlm_PrompT Nlm_StaticPrompt (Nlm_GrouP prnt, Nlm_CharPtr title,
737 Nlm_Int2 pixwidth, Nlm_Int2 pixheight,
738 Nlm_FonT font, Nlm_Char just)
739
740 {
741 Nlm_PoinT npt;
742 Nlm_PrompT p;
743 Nlm_RecT r;
744 Nlm_WindoW tempPort;
745
746 p = NULL;
747 if (prnt != NULL) {
748 tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
749 Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
750 if (font != NULL) {
751 Nlm_SelectFont (font);
752 } else {
753 Nlm_SelectFont (Nlm_systemFont);
754 }
755 if (pixwidth == 0) {
756 pixwidth = Nlm_StringWidth (title) + 2;
757 }
758 if (pixheight == 0) {
759 pixheight = Nlm_LineHeight ();
760 }
761 Nlm_LoadRect(&r, npt.x, npt.y,
762 (Nlm_Int2)(npt.x+pixwidth), (Nlm_Int2)(npt.y+pixheight));
763 p = (Nlm_PrompT) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r, sizeof (Nlm_PromptRec),
764 staticPromptProcs);
765 if (p != NULL) {
766 Nlm_NewPrompt (p, title, font, just);
767 Nlm_DoAdjustPrnt ((Nlm_GraphiC) p, &r, TRUE, FALSE);
768 Nlm_DoShow ((Nlm_GraphiC) p, TRUE, FALSE);
769 }
770 Nlm_SelectFont (Nlm_systemFont);
771 Nlm_RestorePort (tempPort);
772 }
773 return p;
774 }
775
Nlm_FreePrompt(void)776 extern void Nlm_FreePrompt (void)
777
778 {
779 gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemFree (gphprcsptr);
780 }
781
Nlm_InitPrompt(void)782 extern void Nlm_InitPrompt (void)
783
784 {
785 gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemNew (sizeof (Nlm_GphPrcs) * 2);
786
787 promptProcs = &(gphprcsptr [0]);
788 #ifdef WIN_MAC
789 promptProcs->draw = Nlm_DrawPrompt;
790 #endif
791 promptProcs->show = Nlm_ShowPrompt;
792 promptProcs->hide = Nlm_HidePrompt;
793 promptProcs->enable = Nlm_EnablePrompt;
794 promptProcs->disable = Nlm_DisablePrompt;
795 promptProcs->remove = Nlm_RemovePrompt;
796 promptProcs->setTitle = Nlm_SetPromptTitle;
797 promptProcs->getTitle = Nlm_GetPromptTitle;
798 promptProcs->setPosition = Nlm_SetPromptPosition;
799 promptProcs->getPosition = Nlm_GetPromptPosition;
800
801 staticPromptProcs = &(gphprcsptr [1]);
802 #ifdef WIN_MAC
803 staticPromptProcs->draw = Nlm_DrawPrompt;
804 #endif
805 staticPromptProcs->show = Nlm_ShowPrompt;
806 staticPromptProcs->hide = Nlm_HidePrompt;
807 staticPromptProcs->enable = Nlm_EnablePrompt;
808 staticPromptProcs->disable = Nlm_DisablePrompt;
809 staticPromptProcs->remove = Nlm_RemoveLinkedInPrompt;
810 staticPromptProcs->setTitle = Nlm_SetPromptTitle;
811 staticPromptProcs->getTitle = Nlm_GetPromptTitle;
812 staticPromptProcs->setPosition = Nlm_SetPromptPosition;
813 staticPromptProcs->getPosition = Nlm_GetPromptPosition;
814 }
815