1 /* vibgroup.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: vibgroup.c
27 *
28 * Author: Jonathan Kans
29 *
30 * Version Creation Date: 7/1/91
31 *
32 * $Revision: 6.2 $
33 *
34 * File Description:
35 * Vibrant group functions
36 *
37 * Modifications:
38 * --------------------------------------------------------------------------
39 * Date Name Description of modification
40 * ------- ---------- -----------------------------------------------------
41 *
42 *
43 * $Log: vibgroup.c,v $
44 * Revision 6.2 2004/02/03 23:32:25 sinyakov
45 * WIN_MSWIN: use InvalidateRect() to redraw group box inner space after it was moved
46 * instead of UpdateWindow() which redraws only group box frame
47 * Nlm_GroupGainFocus(): call Nlm_GetNext() before calling Nlm_DoGainFocus()
48 *
49 * Revision 6.1 1997/11/26 21:30:20 vakatov
50 * Fixed errors and warnings issued by C and C++ (GNU and Sun) compilers
51 *
52 * Revision 6.0 1997/08/25 18:57:05 madden
53 * Revision changed to 6.0
54 *
55 * Revision 5.1 1997/01/29 16:41:22 kans
56 * using StringNCpy_0
57 *
58 * Revision 5.0 1996/05/28 13:45:08 ostell
59 * Set to revision 5.0
60 *
61 * Revision 4.3 1996/03/26 22:35:37 vakatov
62 * Wrong positioning of the group label caused by the fact that the group
63 * label is not registered as a child of the group -- fixed.
64 *
65 * Revision 4.2 1996/03/02 22:36:38 kans
66 * reduction of X traffic (DV)
67 *
68 * Revision 4.1 1996/02/13 17:24:07 kans
69 * accelerated set position prior to realization (Denis Vakatov)
70 *
71 * Revision 4.0 1995/07/26 13:51:04 ostell
72 * force revision to 4.0
73 *
74 * Revision 2.18 1995/06/08 20:54:43 kans
75 * added Nlm_WindowFrameGroup for Mac, to assist with screen dump figures
76 *
77 * Revision 2.17 1995/05/17 15:15:14 kans
78 * added Log line
79 *
80 *
81 * ==========================================================================
82 */
83
84 #include <vibtypes.h>
85 #include <vibprocs.h>
86 #include <vibincld.h>
87
88 #ifdef WIN_MAC
89 #define Nlm_GroupTool Nlm_PrompT
90 #define Nlm_LineTool Nlm_Handle
91 #endif
92
93 #ifdef WIN_MSWIN
94 #define Nlm_GroupTool HWND
95 #define Nlm_LineTool Nlm_Handle
96 #endif
97
98 #ifdef WIN_MOTIF
99 #define Nlm_GroupTool Nlm_PrompT
100 #define Nlm_LineTool Widget
101 #endif
102
103 typedef struct Nlm_groupdata {
104 Nlm_GroupTool handle;
105 Nlm_LineTool left;
106 Nlm_LineTool top;
107 Nlm_LineTool right;
108 Nlm_LineTool bottom;
109 Nlm_Int2 style;
110 } Nlm_GroupData;
111
112 typedef struct Nlm_grouprec {
113 Nlm_BoxRec boxR;
114 Nlm_GroupData group;
115 } Nlm_GroupRec, PNTR Nlm_GrpPtr;
116
117 static Nlm_GphPrcsPtr gphprcsptr = NULL;
118
119 static Nlm_GphPrcsPtr groupProcs;
120
121 static Nlm_GrouP recentGroup = NULL;
122 static Nlm_GroupData recentGroupData;
123
Nlm_LoadGroupData(Nlm_GrouP g,Nlm_GroupTool hdl,Nlm_LineTool lf,Nlm_LineTool tp,Nlm_LineTool rt,Nlm_LineTool bt,Nlm_Int2 styl)124 static void Nlm_LoadGroupData (Nlm_GrouP g, Nlm_GroupTool hdl,
125 Nlm_LineTool lf, Nlm_LineTool tp,
126 Nlm_LineTool rt, Nlm_LineTool bt,
127 Nlm_Int2 styl)
128
129 {
130 Nlm_GrpPtr gp;
131 Nlm_GroupData PNTR gptr;
132
133 if (g != NULL) {
134 gp = (Nlm_GrpPtr) Nlm_HandLock (g);
135 gptr = &(gp->group);
136 gptr->handle = hdl;
137 gptr->left = lf;
138 gptr->top = tp;
139 gptr->right = rt;
140 gptr->bottom = bt;
141 gptr->style = styl;
142 Nlm_HandUnlock (g);
143 recentGroup = NULL;
144 }
145 }
146
147
Nlm_GetGroupData(Nlm_GrouP g,Nlm_GroupData * gdata)148 static void Nlm_GetGroupData (Nlm_GrouP g, Nlm_GroupData * gdata)
149
150 {
151 Nlm_GrpPtr gp;
152
153 if (g != NULL && gdata != NULL) {
154 if (g == recentGroup && NLM_RISKY) {
155 *gdata = recentGroupData;
156 } else {
157 gp = (Nlm_GrpPtr) Nlm_HandLock (g);
158 *gdata = gp->group;
159 Nlm_HandUnlock (g);
160 recentGroup = g;
161 recentGroupData = *gdata;
162 }
163 }
164 }
165
Nlm_GetGroupHandle(Nlm_GrouP g)166 static Nlm_GroupTool Nlm_GetGroupHandle (Nlm_GrouP g)
167
168 {
169 Nlm_GroupData gdata;
170
171 Nlm_GetGroupData (g, &gdata);
172 return gdata.handle;
173 }
174
175 #ifdef WIN_MAC
176 typedef struct revItem {
177 Nlm_GraphiC graphic;
178 struct revItem PNTR next;
179 } Nlm_RevItem, PNTR Nlm_RevPtr;
180
Nlm_GroupClick(Nlm_GraphiC a,Nlm_PoinT pt)181 static Nlm_Boolean Nlm_GroupClick (Nlm_GraphiC a, Nlm_PoinT pt)
182
183 {
184 Nlm_GraphiC g;
185 Nlm_RevPtr next;
186 Nlm_Boolean notInside;
187 Nlm_RecT r;
188 Nlm_Boolean rsult;
189 Nlm_RevPtr this;
190 Nlm_RevPtr top;
191
192 rsult = FALSE;
193 Nlm_GetRect (a, &r);
194 if (Nlm_PtInRect (pt, &r)) {
195 g = Nlm_GetChild (a);
196 notInside = TRUE;
197 /*
198 while (g != NULL && notInside) {
199 n = Nlm_GetNext (g);
200 if (Nlm_GetEnabled (g) && Nlm_GetVisible (g) && Nlm_DoClick (g, pt)) {
201 notInside = FALSE;
202 }
203 g = n;
204 }
205 */
206 if (g != NULL && notInside) {
207 top = NULL;
208 while (g != NULL) {
209 this = Nlm_MemNew (sizeof (Nlm_RevItem));
210 if (this != NULL) {
211 this->graphic = g;
212 this->next = top;
213 top = this;
214 }
215 g = Nlm_GetNext (g);
216 }
217 this = top;
218 while (this != NULL && notInside) {
219 next = this->next;
220 g = this->graphic;
221 if (Nlm_GetEnabled (g) && Nlm_GetVisible (g) && Nlm_DoClick (g, pt)) {
222 notInside = FALSE;
223 }
224 this = next;
225 }
226 this = top;
227 while (this != NULL) {
228 next = this->next;
229 Nlm_MemFree (this);
230 this = next;
231 }
232 }
233 rsult = (! notInside);
234 }
235 return rsult;
236 }
237
Nlm_GroupKey(Nlm_GraphiC a,Nlm_Char ch)238 static Nlm_Boolean Nlm_GroupKey (Nlm_GraphiC a, Nlm_Char ch)
239
240 {
241 Nlm_GraphiC g;
242 Nlm_GraphiC n;
243 Nlm_Boolean notInside;
244
245 g = Nlm_GetChild (a);
246 notInside = TRUE;
247 while (g != NULL && notInside) {
248 n = Nlm_GetNext (g);
249 if (Nlm_GetEnabled (g) && Nlm_GetVisible (g) && Nlm_DoKey (g, ch)) {
250 notInside = FALSE;
251 }
252 g = n;
253 }
254 return (! notInside);
255 }
256
Nlm_DrawGroup(Nlm_GraphiC a)257 static void Nlm_DrawGroup (Nlm_GraphiC a)
258
259 {
260 Nlm_GraphiC g;
261 Nlm_GroupData gdata;
262 Nlm_GroupTool h;
263 Nlm_Int2 i;
264 Nlm_RecT r;
265
266 if (Nlm_GetVisible (a) && Nlm_GetAllParentsVisible (a)) {
267 Nlm_GetRect (a, &r);
268 Nlm_InsetRect (&r, -4, -4);
269 if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
270 Nlm_InsetRect (&r, 4, 4);
271 Nlm_GetGroupData ((Nlm_GrouP) a, &gdata);
272 h = gdata.handle;
273 if (h != NULL) {
274 if (gdata.style == 0) {
275 r.top += 6;
276 Nlm_FrameRect (&r);
277 Nlm_DoDraw ((Nlm_GraphiC) h);
278 } else {
279 Nlm_FrameRect (&r);
280 r.bottom++;
281 r.right++;
282 Nlm_FrameRect (&r);
283 r.bottom--;
284 r.right--;
285 r.bottom = r.top + 19;
286 if (Nlm_hasColorQD) {
287 Nlm_SelectColor (127, 127, 127);
288 }
289 for (i = 4; i < 16; i += 2) {
290 Nlm_MoveTo (r.left + 2, r.top + i);
291 Nlm_LineTo (r.right - 3, r.top + i);
292 }
293 if (Nlm_hasColorQD) {
294 Nlm_Black ();
295 }
296 Nlm_DoDraw ((Nlm_GraphiC) h);
297 if (Nlm_hasColorQD) {
298 /*
299 Nlm_SelectColor (191, 191, 191);
300 */
301 Nlm_SelectColor (191, 191, 255);
302 }
303 Nlm_MoveTo (r.left + 1, r.top + 1);
304 Nlm_LineTo (r.right - 2, r.top + 1);
305 Nlm_MoveTo (r.left + 1, r.top + 1);
306 Nlm_LineTo (r.left + 1, r.bottom - 2);
307 if (Nlm_hasColorQD) {
308 /*
309 Nlm_SelectColor (159, 159, 159);
310 */
311 Nlm_SelectColor (159, 159, 223);
312 }
313 Nlm_MoveTo (r.left + 1, r.bottom - 2);
314 Nlm_LineTo (r.right - 2, r.bottom - 2);
315 Nlm_MoveTo (r.right - 2, r.top + 1);
316 Nlm_LineTo (r.right - 2, r.bottom - 2);
317 if (Nlm_hasColorQD) {
318 Nlm_Black ();
319 }
320 Nlm_FrameRect (&r);
321 }
322 }
323 g = Nlm_GetChild (a);
324 while (g != NULL) {
325 Nlm_DoDraw (g);
326 g = Nlm_GetNext (g);
327 }
328 }
329 }
330 }
331
Nlm_IdleGroup(Nlm_GraphiC a,Nlm_PoinT pt)332 static Nlm_Boolean Nlm_IdleGroup (Nlm_GraphiC a, Nlm_PoinT pt)
333
334 {
335 Nlm_GraphiC g;
336
337 if (Nlm_GetVisible (a) && Nlm_GetEnabled (a)) {
338 g = Nlm_GetChild (a);
339 while (g != NULL) {
340 Nlm_DoIdle (g, pt);
341 g = Nlm_GetNext (g);
342 }
343 }
344 return TRUE;
345 }
346 #endif
347
Nlm_ShowGroup(Nlm_GraphiC a,Nlm_Boolean setFlag,Nlm_Boolean savePort)348 static void Nlm_ShowGroup (Nlm_GraphiC a, Nlm_Boolean setFlag, Nlm_Boolean savePort)
349
350 {
351 Nlm_GraphiC g;
352 Nlm_GroupTool h;
353 Nlm_WindoW tempPort;
354 #ifdef WIN_MAC
355 Nlm_RecT r;
356 #endif
357 #ifdef WIN_MOTIF
358 Nlm_GroupData gdata;
359 #endif
360
361 tempPort = Nlm_SavePortIfNeeded (a, savePort);
362 if (setFlag) {
363 Nlm_SetVisible (a, TRUE);
364 }
365 if (Nlm_GetVisible (a) && Nlm_AllParentsButWindowVisible (a)) {
366 h = Nlm_GetGroupHandle ((Nlm_GrouP) a);
367 if (h != NULL) {
368 #ifdef WIN_MAC
369 if (Nlm_GetAllParentsVisible (a)) {
370 Nlm_GetRect (a, &r);
371 r.top += 6;
372 Nlm_FrameRect (&r);
373 }
374 Nlm_DoShow ((Nlm_GraphiC) h, TRUE, FALSE);
375 #endif
376 #ifdef WIN_MSWIN
377 ShowWindow (h, SW_SHOW);
378 UpdateWindow (h);
379 #endif
380 #ifdef WIN_MOTIF
381 Nlm_DoShow ((Nlm_GraphiC) h, TRUE, FALSE);
382 Nlm_GetGroupData ((Nlm_GrouP) a, &gdata);
383 XtManageChild (gdata.left);
384 XtManageChild (gdata.top);
385 XtManageChild (gdata.right);
386 XtManageChild (gdata.bottom);
387 #endif
388 }
389 g = Nlm_GetChild (a);
390 while (g != NULL) {
391 Nlm_DoShow (g, FALSE, FALSE);
392 g = Nlm_GetNext (g);
393 }
394 }
395 Nlm_RestorePort (tempPort);
396 }
397
Nlm_HideGroup(Nlm_GraphiC a,Nlm_Boolean setFlag,Nlm_Boolean savePort)398 static void Nlm_HideGroup (Nlm_GraphiC a, Nlm_Boolean setFlag, Nlm_Boolean savePort)
399
400 {
401 Nlm_GraphiC g;
402 Nlm_GroupTool h;
403 Nlm_WindoW tempPort;
404 #ifdef WIN_MAC
405 Nlm_RecT r;
406 #endif
407 #ifdef WIN_MOTIF
408 Nlm_GroupData gdata;
409 #endif
410
411 tempPort = Nlm_SavePortIfNeeded (a, savePort);
412 if (Nlm_AllParentsButWindowVisible (a)) {
413 h = Nlm_GetGroupHandle ((Nlm_GrouP) a);
414 #ifdef WIN_MAC
415 if (h != NULL) {
416 Nlm_DoHide ((Nlm_GraphiC) h, TRUE, FALSE);
417 }
418 if (Nlm_GetAllParentsVisible (a)) {
419 Nlm_GetRect (a, &r);
420 Nlm_InsetRect (&r, -1, -1);
421 /*
422 Nlm_InvalRect (&r);
423 */
424 Nlm_EraseRect (&r);
425 Nlm_ValidRect (&r);
426 }
427 #endif
428 g = Nlm_GetChild (a);
429 while (g != NULL) {
430 Nlm_DoHide (g, FALSE, FALSE);
431 g = Nlm_GetNext (g);
432 }
433 #ifdef WIN_MSWIN
434 if (h != NULL) {
435 ShowWindow (h, SW_HIDE);
436 UpdateWindow (h);
437 }
438 #endif
439 #ifdef WIN_MOTIF
440 if (h != NULL) {
441 Nlm_DoHide ((Nlm_GraphiC) h, TRUE, FALSE);
442 Nlm_GetGroupData ((Nlm_GrouP) a, &gdata);
443 XtUnmanageChild (gdata.left);
444 XtUnmanageChild (gdata.top);
445 XtUnmanageChild (gdata.right);
446 XtUnmanageChild (gdata.bottom);
447 }
448 #endif
449 }
450 if (setFlag) {
451 Nlm_SetVisible (a, FALSE);
452 }
453 Nlm_RestorePort (tempPort);
454 }
455
Nlm_EnableGroup(Nlm_GraphiC a,Nlm_Boolean setFlag,Nlm_Boolean savePort)456 static void Nlm_EnableGroup (Nlm_GraphiC a, Nlm_Boolean setFlag, Nlm_Boolean savePort)
457
458 {
459 Nlm_GraphiC g;
460 Nlm_GroupTool h;
461 Nlm_WindoW tempPort;
462
463 tempPort = Nlm_SavePortIfNeeded (a, savePort);
464 if (setFlag) {
465 Nlm_SetEnabled (a, TRUE);
466 }
467 if (Nlm_GetEnabled (a) && Nlm_GetAllParentsEnabled (a)) {
468 h = Nlm_GetGroupHandle ((Nlm_GrouP) a);
469 if (h != NULL) {
470 #ifdef WIN_MAC
471 Nlm_DoEnable ((Nlm_GraphiC) h, TRUE, FALSE);
472 #endif
473 #ifdef WIN_MSWIN
474 EnableWindow (h, TRUE);
475 #endif
476 #ifdef WIN_MOTIF
477 Nlm_DoEnable ((Nlm_GraphiC) h, TRUE, FALSE);
478 #endif
479 }
480 g = Nlm_GetChild (a);
481 while (g != NULL) {
482 Nlm_DoEnable (g, FALSE, FALSE);
483 g = Nlm_GetNext (g);
484 }
485 }
486 Nlm_RestorePort (tempPort);
487 }
488
Nlm_DisableGroup(Nlm_GraphiC a,Nlm_Boolean setFlag,Nlm_Boolean savePort)489 static void Nlm_DisableGroup (Nlm_GraphiC a, Nlm_Boolean setFlag, Nlm_Boolean savePort)
490
491 {
492 Nlm_GraphiC g;
493 Nlm_GroupTool h;
494 Nlm_WindoW tempPort;
495
496 tempPort = Nlm_SavePortIfNeeded (a, savePort);
497 if (setFlag) {
498 Nlm_SetEnabled (a, FALSE);
499 }
500 h = Nlm_GetGroupHandle ((Nlm_GrouP) a);
501 if (h != NULL) {
502 #ifdef WIN_MAC
503 Nlm_DoDisable ((Nlm_GraphiC) h, TRUE, FALSE);
504 #endif
505 #ifdef WIN_MSWIN
506 EnableWindow (h, FALSE);
507 #endif
508 #ifdef WIN_MOTIF
509 Nlm_DoDisable ((Nlm_GraphiC) h, TRUE, FALSE);
510 #endif
511 }
512 g = Nlm_GetChild (a);
513 while (g != NULL) {
514 Nlm_DoDisable (g, FALSE, FALSE);
515 g = Nlm_GetNext (g);
516 }
517 Nlm_RestorePort (tempPort);
518 }
519
Nlm_ActivateGroup(Nlm_GraphiC a,Nlm_Boolean savePort)520 static void Nlm_ActivateGroup (Nlm_GraphiC a, Nlm_Boolean savePort)
521
522 {
523 Nlm_GraphiC g;
524
525 g = Nlm_GetChild (a);
526 while (g != NULL) {
527 Nlm_DoActivate (g, FALSE);
528 g = Nlm_GetNext (g);
529 }
530 }
531
Nlm_DeactivateGroup(Nlm_GraphiC a,Nlm_Boolean savePort)532 static void Nlm_DeactivateGroup (Nlm_GraphiC a, Nlm_Boolean savePort)
533
534 {
535 Nlm_GraphiC g;
536
537 g = Nlm_GetChild (a);
538 while (g != NULL) {
539 Nlm_DoDeactivate (g, FALSE);
540 g = Nlm_GetNext (g);
541 }
542 }
543
Nlm_ResetGroup(Nlm_GraphiC a,Nlm_Boolean savePort)544 static void Nlm_ResetGroup (Nlm_GraphiC a, Nlm_Boolean savePort)
545
546 {
547 Nlm_GraphiC g;
548 Nlm_GraphiC n;
549 Nlm_WindoW tempPort;
550
551 tempPort = Nlm_SavePortIfNeeded (a, savePort);
552 g = Nlm_GetChild (a);
553 while (g != NULL) {
554 n = Nlm_GetNext (g);
555 Nlm_DoReset (g, FALSE);
556 g = n;
557 }
558 Nlm_RestorePort (tempPort);
559 }
560
Nlm_RemoveGroup(Nlm_GraphiC a,Nlm_Boolean savePort)561 static void Nlm_RemoveGroup (Nlm_GraphiC a, Nlm_Boolean savePort)
562
563 {
564 Nlm_GraphiC g;
565 Nlm_GroupTool h;
566 Nlm_GraphiC n;
567 Nlm_WindoW tempPort;
568 #ifdef WIN_MOTIF
569 Nlm_GroupData gdata;
570 #endif
571
572 tempPort = Nlm_SavePortIfNeeded (a, savePort);
573 g = Nlm_GetChild (a);
574 while (g != NULL) {
575 n = Nlm_GetNext (g);
576 Nlm_DoRemove (g, FALSE);
577 g = n;
578 }
579 h = Nlm_GetGroupHandle ((Nlm_GrouP) a);
580 if (h != NULL) {
581 #ifdef WIN_MAC
582 Nlm_DoRemove ((Nlm_GraphiC) h, FALSE);
583 #endif
584 #ifdef WIN_MSWIN
585 DestroyWindow (h);
586 #endif
587 #ifdef WIN_MOTIF
588 Nlm_DoRemove ((Nlm_GraphiC) h, FALSE);
589 Nlm_GetGroupData ((Nlm_GrouP) a, &gdata);
590 XtDestroyWidget (gdata.left);
591 XtDestroyWidget (gdata.top);
592 XtDestroyWidget (gdata.right);
593 XtDestroyWidget (gdata.bottom);
594 #endif
595 }
596 Nlm_RemoveLink (a);
597 recentGroup = NULL;
598 Nlm_RestorePort (tempPort);
599 }
600
Nlm_SetGroupTitle(Nlm_GraphiC a,Nlm_Int2 item,Nlm_CharPtr title,Nlm_Boolean savePort)601 static void Nlm_SetGroupTitle (Nlm_GraphiC a, Nlm_Int2 item,
602 Nlm_CharPtr title, Nlm_Boolean savePort)
603
604 {
605 Nlm_GraphiC g;
606 Nlm_GroupTool h;
607 Nlm_WindoW tempPort;
608
609 tempPort = Nlm_SavePortIfNeeded (a, savePort);
610 if (item > 0) {
611 g = Nlm_FindItem (a, item);
612 if (g != NULL) {
613 Nlm_DoSetTitle (g, 0, title, FALSE);
614 }
615 } else {
616 h = Nlm_GetGroupHandle ((Nlm_GrouP) a);
617 if (h != NULL) {
618 #ifdef WIN_MAC
619 Nlm_DoSetTitle ((Nlm_GraphiC) h, 0, title, FALSE);
620 #endif
621 #ifdef WIN_MSWIN
622 SetWindowText (h, title);
623 #endif
624 #ifdef WIN_MOTIF
625 #endif
626 }
627 }
628 Nlm_RestorePort (tempPort);
629 }
630
Nlm_GetGroupTitle(Nlm_GraphiC a,Nlm_Int2 item,Nlm_CharPtr title,size_t maxsize)631 static void Nlm_GetGroupTitle (Nlm_GraphiC a, Nlm_Int2 item,
632 Nlm_CharPtr title, size_t maxsize)
633
634 {
635 Nlm_GraphiC g;
636 Nlm_GroupTool h;
637 #ifdef WIN_MSWIN
638 Nlm_Char temp [256];
639 #endif
640
641 if (item > 0) {
642 g = Nlm_FindItem (a, item);
643 if (g != NULL) {
644 Nlm_DoGetTitle (g, 0, title, maxsize);
645 }
646 } else {
647 h = Nlm_GetGroupHandle ((Nlm_GrouP) a);
648 if (h != NULL) {
649 #ifdef WIN_MAC
650 Nlm_DoGetTitle ((Nlm_GraphiC) h, 0, title, maxsize);
651 #endif
652 #ifdef WIN_MSWIN
653 GetWindowText (h, temp, sizeof (temp));
654 Nlm_StringNCpy_0 (title, temp, maxsize);
655 #endif
656 #ifdef WIN_MOTIF
657 #endif
658 }
659 }
660 }
661
Nlm_SetGroupValue(Nlm_GraphiC a,Nlm_Int2 value,Nlm_Boolean savePort)662 static void Nlm_SetGroupValue (Nlm_GraphiC a, Nlm_Int2 value, Nlm_Boolean savePort)
663
664 {
665 Nlm_GraphiC g;
666 Nlm_WindoW tempPort;
667
668 tempPort = Nlm_SavePortIfNeeded (a, savePort);
669 if (value > 0) {
670 g = Nlm_FindItem (a, value);
671 Nlm_ClearItemsInGroup (a, g, FALSE);
672 if (g != NULL) {
673 Nlm_DoSetStatus (g, 0, TRUE, FALSE);
674 }
675 } else {
676 Nlm_ClearItemsInGroup (a, NULL, FALSE);
677 }
678 Nlm_RestorePort (tempPort);
679 }
680
Nlm_GetGroupValue(Nlm_GraphiC a)681 static Nlm_Int2 Nlm_GetGroupValue (Nlm_GraphiC a)
682
683 {
684 Nlm_Boolean found;
685 Nlm_GraphiC g;
686 Nlm_Int2 i;
687 Nlm_Int2 rsult;
688
689 rsult = FALSE;
690 g = Nlm_GetChild (a);
691 i = 0;
692 found = FALSE;
693 while (g != NULL && ! found) {
694 i++;
695 found = Nlm_DoGetStatus (g, 0);
696 g = Nlm_GetNext (g);
697 }
698 if (found) {
699 rsult = i;
700 }
701 return rsult;
702 }
703
Nlm_SetGroupStatus(Nlm_GraphiC a,Nlm_Int2 item,Nlm_Boolean value,Nlm_Boolean savePort)704 static void Nlm_SetGroupStatus (Nlm_GraphiC a, Nlm_Int2 item,
705 Nlm_Boolean value, Nlm_Boolean savePort)
706
707 {
708 Nlm_GraphiC g;
709 Nlm_WindoW tempPort;
710
711 tempPort = Nlm_SavePortIfNeeded (a, savePort);
712 if (item > 0) {
713 g = Nlm_FindItem (a, item);
714 if (g != NULL) {
715 Nlm_DoSetStatus (g, 0, value, FALSE);
716 }
717 }
718 Nlm_RestorePort (tempPort);
719 }
720
Nlm_GetGroupStatus(Nlm_GraphiC a,Nlm_Int2 item)721 static Nlm_Boolean Nlm_GetGroupStatus (Nlm_GraphiC a, Nlm_Int2 item)
722
723 {
724 Nlm_GraphiC g;
725 Nlm_Boolean rsult;
726
727 rsult = FALSE;
728 if (item > 0) {
729 g = Nlm_FindItem (a, item);
730 if (g != NULL) {
731 rsult = Nlm_DoGetStatus (g, 0);
732 }
733 }
734 return rsult;
735 }
736
737 #ifdef WIN_MAC
Nlm_InvalItem(Nlm_GraphiC a)738 static void Nlm_InvalItem (Nlm_GraphiC a)
739
740 {
741 Nlm_RecT r;
742
743 if (Nlm_GetVisible (a) && Nlm_GetAllParentsVisible (a)) {
744 Nlm_GetRect (a, &r);
745 Nlm_InsetRect (&r, -1, -1);
746 Nlm_InvalRect (&r);
747 }
748 }
749 #endif
750
Nlm_InvalGroup(Nlm_GraphiC a)751 static void Nlm_InvalGroup (Nlm_GraphiC a)
752
753 {
754 #ifndef WIN_MOTIF
755 Nlm_RecT r;
756 #endif
757 #ifdef WIN_MSWIN
758 Nlm_RectTool rtool;
759 Nlm_WindowTool wptr;
760 #endif
761
762 if (Nlm_GetVisible (a) && Nlm_GetAllParentsVisible (a)) {
763 #ifdef WIN_MAC
764 Nlm_GetRect (a, &r);
765 Nlm_InsetRect (&r, -1, -1);
766 Nlm_InvalRect (&r);
767 #endif
768 #ifdef WIN_MSWIN
769 wptr = Nlm_ParentWindowPtr (a);
770 Nlm_GetRect (a, &r);
771 r.top = r.bottom - 1;
772 r.bottom++;
773 Nlm_RecTToRectTool (&r, &rtool);
774 InvalidateRect (wptr, &rtool, TRUE);
775 Nlm_GetRect (a, &r);
776 r.left = r.right - 1;
777 r.right++;
778 Nlm_RecTToRectTool (&r, &rtool);
779 InvalidateRect (wptr, &rtool, TRUE);
780 #endif
781 }
782 }
783
784
Nlm_SetGroupPosition(Nlm_GraphiC a,Nlm_RectPtr r,Nlm_Boolean savePort,Nlm_Boolean force)785 static void Nlm_SetGroupPosition (Nlm_GraphiC a, Nlm_RectPtr r, Nlm_Boolean savePort, Nlm_Boolean force)
786
787 {
788 Nlm_GraphiC g;
789 Nlm_RecT gr;
790 Nlm_GroupTool h;
791 Nlm_RecT oldRect;
792 Nlm_WindoW tempPort;
793 Nlm_Int2 deltaX;
794 Nlm_Int2 deltaY;
795 #if defined(WIN_MAC) || defined(WIN_MOTIF)
796 Nlm_Int2 deltaH;
797 Nlm_Int2 deltaW;
798 #endif
799 #ifdef WIN_MOTIF
800 Nlm_GroupData gdata;
801 #endif
802 Nlm_Boolean is_realized;
803
804 if (r == NULL) return;
805
806 Nlm_DoGetPosition (a, &oldRect);
807 if (!force && Nlm_EqualRect(r, &oldRect)) return;
808
809 is_realized = Nlm_GetRealized( a );
810 tempPort = Nlm_SavePortIfNeeded(a, savePort);
811
812 Nlm_GetRect(a, &oldRect);
813 gr = *r;
814 deltaX = gr.left - oldRect.left;
815 deltaY = gr.top - oldRect.top;
816 #if defined(WIN_MAC) || defined(WIN_MOTIF)
817 deltaW = (gr.right - gr.left) - (oldRect.right - oldRect.left);
818 deltaH = (gr.bottom - gr.top ) - (oldRect.bottom - oldRect.top );
819 #endif
820
821 if ( is_realized )
822 Nlm_InvalGroup( a );
823
824 Nlm_SetRect(a, &gr);
825
826 h = Nlm_GetGroupHandle((Nlm_GrouP) a);
827 if (h != NULL)
828 {
829 #if defined(WIN_MAC) || defined(WIN_MOTIF)
830 Nlm_GetRect ((Nlm_GraphiC) h, &gr);
831 Nlm_UpsetRect (&gr, deltaX, deltaY, -deltaX, -deltaY);
832 if (force &&
833 is_realized && !Nlm_GetRealized((Nlm_GraphiC) h ) &&
834 !deltaX && !deltaY && !deltaW && !deltaH)
835 Nlm_SetRealized((Nlm_GraphiC) h, TRUE);
836
837 Nlm_DoSetPosition ((Nlm_GraphiC) h, &gr, FALSE, force);
838 #endif
839
840 if ( is_realized )
841 {
842 #ifdef WIN_MAC
843 Nlm_InvalGroup( a );
844 #endif
845 #ifdef WIN_MSWIN
846 MoveWindow (h, gr.left, gr.top,
847 gr.right - gr.left, gr.bottom - gr.top, TRUE);
848 #endif
849 #ifdef WIN_MOTIF
850 Nlm_GetRect (a, &gr);
851 gr.top += Nlm_stdLineHeight / 2;
852 Nlm_GetGroupData ((Nlm_GrouP) a, &gdata);
853 XtVaSetValues (gdata.left,
854 XmNx, (Position) gr.left,
855 XmNy, (Position) gr.top,
856 XmNwidth, (Dimension) 1,
857 XmNheight, (Dimension) (gr.bottom - gr.top),
858 NULL);
859 XtVaSetValues (gdata.top,
860 XmNx, (Position) gr.left,
861 XmNy, (Position) gr.top,
862 XmNwidth, (Dimension) (gr.right - gr.left),
863 XmNheight, (Dimension) 1,
864 NULL);
865 XtVaSetValues (gdata.right,
866 XmNx, (Position) gr.right,
867 XmNy, (Position) gr.top,
868 XmNwidth, (Dimension) 1,
869 XmNheight, (Dimension) (gr.bottom - gr.top),
870 NULL);
871 XtVaSetValues (gdata.bottom,
872 XmNx, (Position) gr.left,
873 XmNy, (Position) gr.bottom,
874 XmNwidth, (Dimension) (gr.right - gr.left + 1),
875 XmNheight, (Dimension) 1,
876 NULL);
877 #endif
878 }
879 }
880
881 g = Nlm_GetChild( a );
882 while (g != NULL) {
883 Nlm_DoGetPosition (g, &gr);
884 Nlm_OffsetRect (&gr, deltaX, deltaY);
885 Nlm_DoSetPosition (g, &gr, FALSE, force);
886 g = Nlm_GetNext( g );
887 }
888
889 #ifdef WIN_MSWIN
890 if (is_realized && (h != NULL))
891 {
892 Nlm_RecT r;
893 Nlm_RectTool rtool;
894 Nlm_WindowTool wptr;
895 wptr = Nlm_ParentWindowPtr (a);
896 Nlm_GetRect (a, &r);
897 Nlm_RecTToRectTool (&r, &rtool);
898 InvalidateRect (wptr, &rtool, TRUE);
899 }
900 #endif
901
902 Nlm_RestorePort( tempPort );
903 }
904
905
Nlm_GetGroupPosition(Nlm_GraphiC a,Nlm_RectPtr r)906 static void Nlm_GetGroupPosition (Nlm_GraphiC a, Nlm_RectPtr r)
907
908 {
909 Nlm_RecT gr;
910
911 Nlm_GetRect (a, &gr);
912 if (r != NULL) {
913 *r = gr;
914 }
915 }
916
Nlm_GroupGainFocus(Nlm_GraphiC a,Nlm_Char ch,Nlm_Boolean savePort)917 static Nlm_GraphiC Nlm_GroupGainFocus (Nlm_GraphiC a, Nlm_Char ch, Nlm_Boolean savePort)
918
919 {
920 Nlm_GraphiC p;
921 Nlm_GraphiC q;
922 Nlm_GraphiC n;
923
924 q = NULL;
925 if (Nlm_GetVisible (a) && Nlm_GetEnabled (a)) {
926 p = Nlm_GetChild (a);
927 while (p != NULL && q == NULL) {
928 n = Nlm_GetNext (p);
929 q = Nlm_DoGainFocus (p, ch, savePort);
930 p = n;
931 }
932 }
933 return q;
934 }
935
Nlm_GroupLoseFocus(Nlm_GraphiC a,Nlm_GraphiC excpt,Nlm_Boolean savePort)936 static void Nlm_GroupLoseFocus (Nlm_GraphiC a, Nlm_GraphiC excpt, Nlm_Boolean savePort)
937
938 {
939 Nlm_GraphiC p;
940
941 p = Nlm_GetChild (a);
942 while (p != NULL) {
943 Nlm_DoLoseFocus (p, excpt, savePort);
944 p = Nlm_GetNext (p);
945 }
946 }
947
Nlm_RepositionHorizItems(Nlm_GraphiC a,Nlm_Int2 count,Nlm_Int2 width,Nlm_Boolean align)948 static void Nlm_RepositionHorizItems (Nlm_GraphiC a, Nlm_Int2 count,
949 Nlm_Int2 width, Nlm_Boolean align)
950
951 {
952 Nlm_BoxData bdata;
953 Nlm_Int2 col;
954 Nlm_Int2 column;
955 Nlm_Int2 curWdt;
956 Nlm_GrouP g;
957 Nlm_Int2 i;
958 Nlm_Int2 newWdt;
959 Nlm_Int2 offset;
960 Nlm_GraphiC p;
961 Nlm_RecT r;
962 Nlm_RecT s;
963 Nlm_GraphiC top;
964 Nlm_RecT topRect;
965 Nlm_Int2 topWdt;
966
967 column = (count - 1) % width + 1;
968 g = (Nlm_GrouP) Nlm_GetParent (a);
969 top = Nlm_FindItem ((Nlm_GraphiC) g, column);
970 Nlm_DoGetPosition (a, &r);
971 Nlm_DoGetPosition (top, &topRect);
972 curWdt = r.right - r.left;
973 topWdt = topRect.right - topRect.left;
974 newWdt = MAX (curWdt, topWdt);
975 if (curWdt < newWdt) {
976 r.right = r.left + newWdt;
977 Nlm_DoSetPosition (a, &r, FALSE, FALSE);
978 curWdt = newWdt;
979 }
980 if (newWdt > topWdt) {
981 offset = newWdt - topWdt;
982 i = 1;
983 p = Nlm_GetChild ((Nlm_GraphiC) g);
984 while (p != NULL) {
985 col = (i - 1) % width + 1;
986 if (col == column) {
987 Nlm_DoGetPosition (p, &r);
988 r.right = r.left + newWdt;
989 Nlm_DoSetPosition (p, &r, FALSE, FALSE);
990 Nlm_RecordRect ((Nlm_GraphiC) g, &r);
991 } else if (col > column) {
992 Nlm_DoGetPosition (p, &r);
993 Nlm_OffsetRect (&r, offset, 0);
994 Nlm_DoSetPosition (p, &r, FALSE, FALSE);
995 Nlm_RecordRect ((Nlm_GraphiC) g, &r);
996 }
997 i++;
998 p = Nlm_GetNext (p);
999 }
1000 }
1001 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1002 Nlm_GetRect ((Nlm_GraphiC) g, &s);
1003 Nlm_GetBoxData ((Nlm_BoX) g, &bdata);
1004 s.right = MAX (r.right, bdata.limitPoint.x + bdata.xMargin);
1005 s.bottom = bdata.limitPoint.y + bdata.yMargin;
1006 Nlm_SetRect ((Nlm_GraphiC) g, &s);
1007 r.right = bdata.limitPoint.x + bdata.xMargin;
1008 r.bottom = bdata.limitPoint.y + bdata.yMargin;
1009 Nlm_DoAdjustPrnt ((Nlm_GraphiC) g, &r, align, FALSE);
1010 Nlm_DoGetPosition (a, &r);
1011 bdata.nextCol = r.right + bdata.xSpacing;
1012 Nlm_SetBoxData ((Nlm_BoX) g, &bdata);
1013 }
1014
Nlm_RepositionVertItems(Nlm_GraphiC a,Nlm_Int2 count,Nlm_Int2 height,Nlm_Boolean align)1015 static void Nlm_RepositionVertItems (Nlm_GraphiC a, Nlm_Int2 count,
1016 Nlm_Int2 height, Nlm_Boolean align)
1017
1018 {
1019 Nlm_BoxData bdata;
1020 Nlm_Int2 column;
1021 Nlm_Int2 curWdt;
1022 Nlm_GrouP g;
1023 Nlm_Int2 newWdt;
1024 Nlm_GraphiC p;
1025 Nlm_RecT r;
1026 Nlm_RecT s;
1027 Nlm_GraphiC top;
1028 Nlm_RecT topRect;
1029 Nlm_Int2 topWdt;
1030
1031 column = (count - 1) / height + 1;
1032 g = (Nlm_GrouP) Nlm_GetParent (a);
1033 top = Nlm_FindItem ((Nlm_GraphiC) g, (column - 1) * height + 1);
1034 Nlm_DoGetPosition (a, &r);
1035 Nlm_DoGetPosition (top, &topRect);
1036 curWdt = r.right - r.left;
1037 topWdt = topRect.right - topRect.left;
1038 newWdt = MAX (curWdt, topWdt);
1039 if (curWdt < newWdt) {
1040 r.right = r.left + newWdt;
1041 Nlm_DoSetPosition (a, &r, FALSE, FALSE);
1042 Nlm_RecordRect ((Nlm_GraphiC) g, &r);
1043 curWdt = newWdt;
1044 }
1045 if (newWdt > topWdt) {
1046 p = top;
1047 while (p != NULL && p != a) {
1048 Nlm_DoGetPosition (p, &r);
1049 r.right = r.left + newWdt;
1050 Nlm_DoSetPosition (p, &r, FALSE, FALSE);
1051 Nlm_RecordRect ((Nlm_GraphiC) g, &r);
1052 p = Nlm_GetNext (p);
1053 }
1054 }
1055 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1056 Nlm_GetRect ((Nlm_GraphiC) g, &s);
1057 Nlm_GetBoxData ((Nlm_BoX) g, &bdata);
1058 s.right = MAX (r.right, bdata.limitPoint.x + bdata.xMargin);
1059 s.bottom = bdata.limitPoint.y + bdata.yMargin;
1060 Nlm_SetRect ((Nlm_GraphiC) g, &s);
1061 r.right = bdata.limitPoint.x + bdata.xMargin;
1062 r.bottom = bdata.limitPoint.y + bdata.yMargin;
1063 Nlm_DoAdjustPrnt ((Nlm_GraphiC) g, &r, align, FALSE);
1064 Nlm_DoGetPosition (a, &r);
1065 bdata.nextCol = r.right + bdata.xSpacing;
1066 Nlm_SetBoxData ((Nlm_BoX) g, &bdata);
1067 }
1068
Nlm_FinishItemPositioning(Nlm_GraphiC a,Nlm_RectPtr subRect,Nlm_Boolean align,Nlm_Boolean savePort)1069 static void Nlm_FinishItemPositioning (Nlm_GraphiC a, Nlm_RectPtr subRect,
1070 Nlm_Boolean align, Nlm_Boolean savePort)
1071
1072 {
1073 Nlm_BoxData bdata;
1074 Nlm_Int2 count;
1075 Nlm_GrouP g;
1076 Nlm_Int2 height;
1077 Nlm_RecT r;
1078 Nlm_RecT s;
1079 Nlm_WindoW tempPort;
1080 Nlm_Int2 width;
1081 #ifdef WIN_MAC
1082 Nlm_GroupData gdata;
1083 Nlm_GroupTool h;
1084 Nlm_RecT hr;
1085 Nlm_Int2 mid;
1086 Nlm_Int2 wid;
1087 #endif
1088 #ifdef WIN_MSWIN
1089 Nlm_GroupTool h;
1090 #endif
1091 #ifdef WIN_MOTIF
1092 Nlm_GroupData gdata;
1093 Nlm_RecT gr;
1094 Nlm_GroupTool h;
1095 #endif
1096
1097 tempPort = Nlm_SavePortIfNeeded (a, savePort);
1098 g = (Nlm_GrouP) Nlm_GetParent (a);
1099 Nlm_InvalGroup ((Nlm_GraphiC) g);
1100 Nlm_RecordRect ((Nlm_GraphiC) g, subRect);
1101 if (align) {
1102 Nlm_GetBoxData ((Nlm_BoX) g, &bdata);
1103 if (bdata.boxWidth != 0 || bdata.boxHeight != 0) {
1104 Nlm_NextPosition ((Nlm_GraphiC) g, subRect);
1105 }
1106 }
1107 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1108 Nlm_GetRect ((Nlm_GraphiC) g, &s);
1109 Nlm_GetBoxData ((Nlm_BoX) g, &bdata);
1110 s.right = MAX (r.right, bdata.limitPoint.x + bdata.xMargin);
1111 s.bottom = bdata.limitPoint.y + bdata.yMargin;
1112 Nlm_SetRect ((Nlm_GraphiC) g, &s);
1113 r.right = bdata.limitPoint.x + bdata.xMargin;
1114 r.bottom = bdata.limitPoint.y + bdata.yMargin;
1115 Nlm_DoAdjustPrnt ((Nlm_GraphiC) g, &r, align, FALSE);
1116 #ifdef WIN_MAC
1117 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1118 Nlm_GetGroupData ((Nlm_GrouP) g, &gdata);
1119 if (gdata.style > 0) {
1120 h = gdata.handle;
1121 if (h != NULL) {
1122 Nlm_GetPosition ((Nlm_GraphiC) h, &hr);
1123 wid = hr.right - hr.left;
1124 mid = (r.left + r.right) / 2;
1125 hr.left = mid - (wid / 2);
1126 hr.right = hr.left + wid;
1127 Nlm_SetPosition ((Nlm_GraphiC) h, &hr);
1128 }
1129 }
1130 #endif
1131 if (align) {
1132 count = Nlm_CountGroupItems ((Nlm_GraphiC) g);
1133 width = bdata.boxWidth;
1134 height = bdata.boxHeight;
1135 if (width != 0) {
1136 if (width > 0 && count > width) {
1137 Nlm_RepositionHorizItems (a, count, width, align);
1138 }
1139 Nlm_Advance ((Nlm_GraphiC) g);
1140 if ((count % ABS (width)) == 0) {
1141 Nlm_Break ((Nlm_GraphiC) g);
1142 }
1143 } else if (height != 0) {
1144 if (height > 0 && count > 1) {
1145 Nlm_RepositionVertItems (a, count, height, align);
1146 }
1147 if ((count % ABS (height)) == 0) {
1148 Nlm_Advance ((Nlm_GraphiC) g);
1149 }
1150 }
1151 }
1152 #ifdef WIN_MAC
1153 Nlm_InvalGroup ((Nlm_GraphiC) g);
1154 Nlm_InvalItem (a);
1155 #endif
1156 #ifdef WIN_MSWIN
1157 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1158 h = Nlm_GetGroupHandle (g);
1159 if (h != NULL) {
1160 MoveWindow (h, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE);
1161 UpdateWindow (h);
1162 }
1163 #endif
1164 #ifdef WIN_MOTIF
1165 h = Nlm_GetGroupHandle (g);
1166 if (h != NULL) {
1167 Nlm_GetRect ((Nlm_GraphiC) g, &gr);
1168 gr.top += Nlm_stdLineHeight / 2;
1169 Nlm_GetGroupData ((Nlm_GrouP) g, &gdata);
1170 XtVaSetValues (gdata.left,
1171 XmNx, (Position) gr.left,
1172 XmNy, (Position) gr.top,
1173 XmNwidth, (Dimension) 1,
1174 XmNheight, (Dimension) (gr.bottom - gr.top),
1175 NULL);
1176 XtVaSetValues (gdata.top,
1177 XmNx, (Position) gr.left,
1178 XmNy, (Position) gr.top,
1179 XmNwidth, (Dimension) (gr.right - gr.left),
1180 XmNheight, (Dimension) 1,
1181 NULL);
1182 XtVaSetValues (gdata.right,
1183 XmNx, (Position) gr.right,
1184 XmNy, (Position) gr.top,
1185 XmNwidth, (Dimension) 1,
1186 XmNheight, (Dimension) (gr.bottom - gr.top),
1187 NULL);
1188 XtVaSetValues (gdata.bottom,
1189 XmNx, (Position) gr.left,
1190 XmNy, (Position) gr.bottom,
1191 XmNwidth, (Dimension) (gr.right - gr.left + 1),
1192 XmNheight, (Dimension) 1,
1193 NULL);
1194 }
1195 #endif
1196 Nlm_RestorePort (tempPort);
1197 }
1198
1199
1200 #ifdef WIN_MOTIF
Nlm_CreateSeparator(Nlm_GrouP g,Nlm_RectPtr gr,Nlm_Int2 which)1201 static Nlm_LineTool Nlm_CreateSeparator (Nlm_GrouP g, Nlm_RectPtr gr, Nlm_Int2 which)
1202
1203 {
1204 Nlm_LineTool h;
1205 Dimension height;
1206 Cardinal n;
1207 unsigned char orient;
1208 Nlm_RecT r;
1209 unsigned char separat;
1210 Arg wargs [20];
1211 Dimension width;
1212 Nlm_WindowTool wptr;
1213
1214 r = *gr;
1215 r.top += Nlm_stdLineHeight / 2;
1216 switch (which) {
1217 case 1:
1218 orient = XmVERTICAL;
1219 separat = XmSINGLE_LINE;
1220 r.right = r.left;
1221 width = (Dimension) 1;
1222 height = (Dimension) (r.bottom - r.top);
1223 break;
1224 case 2:
1225 orient = XmHORIZONTAL;
1226 separat = XmSINGLE_LINE;
1227 r.bottom = r.top;
1228 width = (Dimension) (r.right - r.left);
1229 height = (Dimension) 1;
1230 break;
1231 case 3:
1232 orient = XmVERTICAL;
1233 separat = XmSINGLE_LINE;
1234 r.left = r.right;
1235 width = (Dimension) 1;
1236 height = (Dimension) (r.bottom - r.top);
1237 break;
1238 case 4:
1239 orient = XmHORIZONTAL;
1240 separat = XmSINGLE_LINE;
1241 r.top = r.bottom;
1242 width = (Dimension) (r.right - r.left + 1);
1243 height = (Dimension) 1;
1244 break;
1245 default:
1246 width = (Dimension) (r.right - r.left);
1247 height = (Dimension) (r.bottom - r.top);
1248 orient = XmHORIZONTAL;
1249 separat = XmSINGLE_LINE;
1250 break;
1251 }
1252 n = 0;
1253 XtSetArg (wargs [n], XmNx, (Position) r.left); n++;
1254 XtSetArg (wargs [n], XmNy, (Position) r.top); n++;
1255 XtSetArg (wargs [n], XmNwidth, (Dimension) width); n++;
1256 XtSetArg (wargs [n], XmNheight, (Dimension) height); n++;
1257 XtSetArg (wargs [n], XmNmarginHeight, 0); n++;
1258 XtSetArg (wargs [n], XmNmarginWidth, 0); n++;
1259 XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
1260 XtSetArg (wargs [n], XmNmargin, (Dimension) 0); n++;
1261 XtSetArg (wargs [n], XmNhighlightThickness, (Dimension) 0); n++;
1262 XtSetArg (wargs [n], XmNshadowThickness, (Dimension) 0); n++;
1263 XtSetArg (wargs [n], XmNorientation, orient); n++;
1264 XtSetArg (wargs [n], XmNseparatorType, separat); n++;
1265 wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) g);
1266 h = XmCreateSeparator (wptr, (String) "", wargs, n);
1267 XtManageChild (h);
1268 return h;
1269 }
1270 #endif
1271
1272
Nlm_NewGroup(Nlm_GrouP g,Nlm_CharPtr title,Nlm_Int2 width,Nlm_Int2 height,Nlm_Boolean visible,Nlm_RectPtr pr,Nlm_FonT font,Nlm_Int2 styl,Nlm_GrpActnProc actn)1273 static void Nlm_NewGroup (Nlm_GrouP g, Nlm_CharPtr title,
1274 Nlm_Int2 width, Nlm_Int2 height,
1275 Nlm_Boolean visible, Nlm_RectPtr pr,
1276 Nlm_FonT font, Nlm_Int2 styl,
1277 Nlm_GrpActnProc actn)
1278
1279 {
1280 Nlm_LineTool bt;
1281 Nlm_GroupTool h;
1282 Nlm_LineTool lf;
1283 Nlm_PoinT pt;
1284 Nlm_RecT r;
1285 Nlm_LineTool rt;
1286 Nlm_LineTool tp;
1287 #ifdef WIN_MSWIN
1288 Nlm_FntPtr fntptr;
1289 Nlm_WindowTool wptr;
1290 #endif
1291
1292 lf = NULL;
1293 tp = NULL;
1294 rt = NULL;
1295 bt = NULL;
1296 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1297 if (styl > 0) {
1298 pt.x = r.left + 3;
1299 pt.y = r.top + Nlm_LineHeight () + 13;
1300 } else if (visible) {
1301 pt.x = r.left + 3;
1302 pt.y = r.top + Nlm_LineHeight () + 2;
1303 } else {
1304 pt.x = r.left;
1305 pt.y = r.top;
1306 }
1307 if (styl > 0) {
1308 Nlm_LoadBoxData ((Nlm_BoX) g, pt, pt, pt, pt.y, pt.x, 12, 12, 3, 2, width, height);
1309 } else if (visible) {
1310 Nlm_LoadBoxData ((Nlm_BoX) g, pt, pt, pt, pt.y, pt.x, 3, 3, 3, 2, width, height);
1311 } else {
1312 Nlm_LoadBoxData ((Nlm_BoX) g, pt, pt, pt, pt.y, pt.x, 0, 0, 3, 2, width, height);
1313 }
1314 h = NULL;
1315 if (visible) {
1316 #ifdef WIN_MAC
1317 if (styl > 0) {
1318 h = Nlm_DependentPrompt ((Nlm_GraphiC) g, pr, title, font, 'c');
1319 } else {
1320 h = Nlm_DependentPrompt ((Nlm_GraphiC) g, pr, title, font, 'l');
1321 }
1322 #endif
1323 #ifdef WIN_MSWIN
1324 wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) g);
1325 h = CreateWindow ("Button", title, WS_CHILD | BS_GROUPBOX,
1326 r.left, r.top, r.right - r.left,
1327 r.bottom - r.top, wptr, 0,
1328 Nlm_currentHInst, NULL);
1329 if (font != NULL) {
1330 fntptr = (Nlm_FntPtr) Nlm_HandLock (font);
1331 if (fntptr != NULL && fntptr->handle != NULL) {
1332 SetWindowFont (h, fntptr->handle, FALSE);
1333 }
1334 Nlm_HandUnlock (font);
1335 }
1336 #endif
1337 #ifdef WIN_MOTIF
1338 h = Nlm_DependentPrompt ((Nlm_GraphiC) g, pr, title, font, 'l');
1339 lf = Nlm_CreateSeparator (g, &r, 1);
1340 tp = Nlm_CreateSeparator (g, &r, 2);
1341 rt = Nlm_CreateSeparator (g, &r, 3);
1342 bt = Nlm_CreateSeparator (g, &r, 4);
1343 #endif
1344 }
1345 Nlm_LoadGroupData (g, h, lf, tp, rt, bt, styl);
1346 Nlm_LoadAction ((Nlm_GraphiC) g, (Nlm_ActnProc) actn);
1347 }
1348
Nlm_CreateGroup(Nlm_GrouP prnt,Nlm_Int2 recordSize,Nlm_Int2 width,Nlm_Int2 height,Nlm_Boolean visible,Nlm_CharPtr title,Nlm_FonT font,Nlm_Int2 styl,Nlm_GrpActnProc actn)1349 static Nlm_GrouP Nlm_CreateGroup (Nlm_GrouP prnt, Nlm_Int2 recordSize,
1350 Nlm_Int2 width, Nlm_Int2 height,
1351 Nlm_Boolean visible, Nlm_CharPtr title,
1352 Nlm_FonT font, Nlm_Int2 styl,
1353 Nlm_GrpActnProc actn)
1354
1355 {
1356 Nlm_GrouP g;
1357 Nlm_Int2 lf;
1358 Nlm_Int2 mid;
1359 Nlm_PoinT npt;
1360 Nlm_RecT pr;
1361 Nlm_RecT r;
1362 Nlm_WindoW tempPort;
1363 Nlm_Int2 top;
1364 Nlm_Int2 wid;
1365
1366 g = NULL;
1367 if (prnt != NULL) {
1368 tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
1369 Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
1370 if (font == NULL) {
1371 font = Nlm_systemFont;
1372 }
1373 Nlm_SelectFont (font);
1374 wid = Nlm_StringWidth (title);
1375 #ifdef WIN_MAC
1376 top = Nlm_LineHeight ();
1377 #endif
1378 #ifdef WIN_MSWIN
1379 top = Nlm_LineHeight ();
1380 #endif
1381 #ifdef WIN_MOTIF
1382 top = Nlm_LineHeight ();
1383 #endif
1384 if (visible) {
1385 Nlm_LoadRect (&r, npt.x, npt.y, npt.x + wid + 20, npt.y + 23);
1386 } else {
1387 Nlm_LoadRect (&r, npt.x, npt.y, npt.x, npt.y);
1388 }
1389 g = (Nlm_GrouP) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r, recordSize, groupProcs);
1390 if (g != NULL) {
1391 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1392 if (styl == 0) {
1393 Nlm_LoadRect (&pr, r.left + 4, r.top, r.left + wid + 6, r.top + top);
1394 } else {
1395 mid = (r.left + r.right) / 2;
1396 wid += 10;
1397 lf = mid - (wid / 2) - 1;
1398 Nlm_LoadRect (&pr, lf, r.top + 2, lf + wid, r.top + top + 2);
1399 }
1400 Nlm_NewGroup (g, title, width, height, visible, &pr, font, styl, actn);
1401 Nlm_DoAdjustPrnt ((Nlm_GraphiC) g, &r, TRUE, FALSE);
1402 Nlm_DoShow ((Nlm_GraphiC) g, TRUE, FALSE);
1403 }
1404 Nlm_RestorePort (tempPort);
1405 }
1406 return g;
1407 }
1408
Nlm_NormalGroup(Nlm_GrouP prnt,Nlm_Int2 width,Nlm_Int2 height,Nlm_CharPtr title,Nlm_FonT font,Nlm_GrpActnProc actn)1409 extern Nlm_GrouP Nlm_NormalGroup (Nlm_GrouP prnt, Nlm_Int2 width,
1410 Nlm_Int2 height, Nlm_CharPtr title,
1411 Nlm_FonT font, Nlm_GrpActnProc actn)
1412
1413 {
1414 Nlm_GrouP g;
1415
1416 g = Nlm_CreateGroup (prnt, sizeof (Nlm_GroupRec), width,
1417 height, TRUE, title, font, 0, actn);
1418 return g;
1419 }
1420
Nlm_HiddenGroup(Nlm_GrouP prnt,Nlm_Int2 width,Nlm_Int2 height,Nlm_GrpActnProc actn)1421 extern Nlm_GrouP Nlm_HiddenGroup (Nlm_GrouP prnt, Nlm_Int2 width,
1422 Nlm_Int2 height, Nlm_GrpActnProc actn)
1423
1424 {
1425 Nlm_GrouP g;
1426
1427 g = Nlm_CreateGroup (prnt, sizeof (Nlm_GroupRec), width,
1428 height, FALSE, "", NULL, 0, actn);
1429 return g;
1430 }
1431
1432 extern Nlm_GrouP Nlm_WindowFrameGroup (Nlm_GrouP prnt, Nlm_Int2 width,
1433 Nlm_Int2 height, Nlm_CharPtr title,
1434 Nlm_FonT font, Nlm_GrpActnProc actn);
Nlm_WindowFrameGroup(Nlm_GrouP prnt,Nlm_Int2 width,Nlm_Int2 height,Nlm_CharPtr title,Nlm_FonT font,Nlm_GrpActnProc actn)1435 extern Nlm_GrouP Nlm_WindowFrameGroup (Nlm_GrouP prnt, Nlm_Int2 width,
1436 Nlm_Int2 height, Nlm_CharPtr title,
1437 Nlm_FonT font, Nlm_GrpActnProc actn)
1438
1439 {
1440 Nlm_GrouP g;
1441
1442 g = Nlm_CreateGroup (prnt, sizeof (Nlm_GroupRec), width,
1443 height, TRUE, title, font, 1, actn);
1444 return g;
1445 }
1446
Nlm_SetGroupMargins(Nlm_GrouP g,Nlm_Int2 xMargin,Nlm_Int2 yMargin)1447 extern void Nlm_SetGroupMargins (Nlm_GrouP g, Nlm_Int2 xMargin, Nlm_Int2 yMargin)
1448
1449 {
1450 Nlm_BoxData bdata;
1451 Nlm_GroupTool h;
1452 Nlm_PoinT pt;
1453 Nlm_RecT r;
1454
1455 if (g != NULL) {
1456 Nlm_GetRect ((Nlm_GraphiC) g, &r);
1457 Nlm_GetBoxData ((Nlm_BoX) g, &bdata);
1458 bdata.xMargin = xMargin;
1459 bdata.yMargin = yMargin;
1460 h = Nlm_GetGroupHandle (g);
1461 if (h != NULL) {
1462 pt.x = r.left + xMargin;
1463 pt.y = r.top + Nlm_stdLineHeight + yMargin;
1464 } else {
1465 pt.x = r.left + xMargin;
1466 pt.y = r.top + yMargin;
1467 }
1468 bdata.nextPoint = pt;
1469 bdata.limitPoint = pt;
1470 bdata.resetPoint = pt;
1471 bdata.nextCol = pt.x;
1472 bdata.topRow = pt.y;
1473 Nlm_SetBoxData ((Nlm_BoX) g, &bdata);
1474 }
1475 }
1476
Nlm_SetGroupSpacing(Nlm_GrouP g,Nlm_Int2 xSpacing,Nlm_Int2 ySpacing)1477 extern void Nlm_SetGroupSpacing (Nlm_GrouP g, Nlm_Int2 xSpacing, Nlm_Int2 ySpacing)
1478
1479 {
1480 Nlm_BoxData bdata;
1481
1482 if (g != NULL) {
1483 Nlm_GetBoxData ((Nlm_BoX) g, &bdata);
1484 bdata.xSpacing = xSpacing;
1485 bdata.ySpacing = ySpacing;
1486 Nlm_SetBoxData ((Nlm_BoX) g, &bdata);
1487 }
1488 }
1489
Nlm_FreeGroup(void)1490 extern void Nlm_FreeGroup (void)
1491
1492 {
1493 gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemFree (gphprcsptr);
1494 }
1495
Nlm_InitGroup(void)1496 extern void Nlm_InitGroup (void)
1497
1498 {
1499 gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemNew (sizeof (Nlm_GphPrcs) * 1);
1500
1501 groupProcs = &(gphprcsptr [0]);
1502 #ifdef WIN_MAC
1503 groupProcs->click = Nlm_GroupClick;
1504 groupProcs->key = Nlm_GroupKey;
1505 groupProcs->draw = Nlm_DrawGroup;
1506 groupProcs->idle = Nlm_IdleGroup;
1507 #endif
1508 groupProcs->show = Nlm_ShowGroup;
1509 groupProcs->hide = Nlm_HideGroup;
1510 groupProcs->enable = Nlm_EnableGroup;
1511 groupProcs->disable = Nlm_DisableGroup;
1512 groupProcs->activate = Nlm_ActivateGroup;
1513 groupProcs->deactivate = Nlm_DeactivateGroup;
1514 groupProcs->remove = Nlm_RemoveGroup;
1515 groupProcs->reset = Nlm_ResetGroup;
1516 groupProcs->countItems = Nlm_CountGroupItems;
1517 groupProcs->linkIn = Nlm_LinkIn;
1518 groupProcs->adjustPrnt = Nlm_FinishItemPositioning;
1519 groupProcs->setTitle = Nlm_SetGroupTitle;
1520 groupProcs->getTitle = Nlm_GetGroupTitle;
1521 groupProcs->setValue = Nlm_SetGroupValue;
1522 groupProcs->getValue = Nlm_GetGroupValue;
1523 groupProcs->setStatus = Nlm_SetGroupStatus;
1524 groupProcs->getStatus = Nlm_GetGroupStatus;
1525 groupProcs->setPosition = Nlm_SetGroupPosition;
1526 groupProcs->getPosition = Nlm_GetGroupPosition;
1527 groupProcs->gainFocus = Nlm_GroupGainFocus;
1528 groupProcs->loseFocus = Nlm_GroupLoseFocus;
1529 }
1530