NCBI C Toolkit Cross Reference

C/vibrant/vibbutns.c


  1 /*   vibbutns.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:  vibbutns.c
 27 *
 28 * Author:  Jonathan Kans
 29 *
 30 * Version Creation Date:   7/1/91
 31 *
 32 * $Revision: 6.13 $
 33 *
 34 * File Description: 
 35 *       Vibrant button functions
 36 *
 37 * Modifications:  
 38 * --------------------------------------------------------------------------
 39 * Date     Name        Description of modification
 40 * -------  ----------  -----------------------------------------------------
 41 *
 42 * ==========================================================================
 43 */
 44 
 45 #include <vibtypes.h>
 46 #include <vibprocs.h>
 47 #include <vibincld.h>
 48 
 49 #ifdef WIN_MAC
 50 #  define Nlm_ControlTool ControlHandle
 51 #endif
 52 
 53 #ifdef WIN_MSWIN
 54 #  define Nlm_ControlTool HWND
 55 #endif
 56 
 57 #ifdef WIN_MOTIF
 58 #  define Nlm_ControlTool Widget
 59 #endif
 60 
 61 typedef  struct  Nlm_buttondata {
 62   Nlm_ControlTool  handle;
 63   Nlm_Int2         border;
 64   Nlm_Int2         offset;
 65   Nlm_Int2         shrinkX;
 66   Nlm_Int2         shrinkY;
 67   Nlm_Boolean      defaultBtn;
 68 } Nlm_ButtonData;
 69 
 70 typedef  struct  Nlm_buttonrec {
 71   Nlm_GraphicRec  graphicR;
 72   Nlm_ButtonData  button;
 73 } Nlm_ButtonRec, PNTR Nlm_BtnPtr;
 74 
 75 static Nlm_GphPrcsPtr  gphprcsptr = NULL;
 76 
 77 static Nlm_GphPrcsPtr  pushProcs;
 78 static Nlm_GphPrcsPtr  defaultProcs;
 79 static Nlm_GphPrcsPtr  checkProcs;
 80 static Nlm_GphPrcsPtr  radioProcs;
 81 
 82 static Nlm_ButtoN      recentButton = NULL;
 83 static Nlm_ButtonData  recentButtonData;
 84 
 85 #ifdef WIN_MSWIN
 86 static WNDPROC         lpfnNewButtonProc = NULL;
 87 static WNDPROC         lpfnOldButtonProc = NULL;
 88 static Nlm_Boolean     handlechar;
 89 #endif
 90 
 91 #ifdef WIN_MOTIF
 92 static void NlmHint_ResetDefButtonE(Widget w, XtPointer client_data,
 93                                     XEvent *event,
 94                                     Boolean *continue_to_dispatch);
 95 static void NlmHint_ResetDefButtonA(Widget w, XtPointer client_data,
 96                                     XtPointer call_data);
 97 #endif
 98 
 99 static void Nlm_LoadButtonData (Nlm_ButtoN b, Nlm_ControlTool hdl,
100                                 Nlm_Int2 bdr, Nlm_Int2 ofs,
101                                 Nlm_Int2 shkX, Nlm_Int2 shkY,
102                                 Nlm_Boolean dflt)
103 
104 {
105   Nlm_BtnPtr      bp;
106   Nlm_ButtonData  PNTR ptr;
107 
108   if (b != NULL) {
109     bp = (Nlm_BtnPtr) Nlm_HandLock (b);
110     ptr = &(bp->button);
111     ptr->handle = hdl;
112     ptr->border = bdr;
113     ptr->offset = ofs;
114     ptr->shrinkX = shkX;
115     ptr->shrinkY = shkY;
116     ptr->defaultBtn = dflt;
117     Nlm_HandUnlock (b);
118     recentButton = NULL;
119   }
120 }
121 
122 
123 static void Nlm_GetButtonData (Nlm_ButtoN b, Nlm_ButtonData * bdata)
124 {
125   Nlm_BtnPtr  bp;
126 
127   if (b != NULL && bdata != NULL) {
128     if (b == recentButton && NLM_RISKY) {
129       *bdata = recentButtonData;
130     } else {
131       bp = (Nlm_BtnPtr) Nlm_HandLock (b);
132       *bdata = bp->button;
133       Nlm_HandUnlock (b);
134       recentButton = b;
135       recentButtonData = *bdata;
136     }
137   }
138 }
139 
140 static Nlm_ControlTool Nlm_GetButtonHandle (Nlm_ButtoN b)
141 
142 {
143   Nlm_ButtonData  bdata;
144 
145   Nlm_GetButtonData (b, &bdata);
146   return bdata.handle;
147 }
148 
149 
150 #ifdef WIN_MAC
151 static Nlm_Int2 Nlm_GetButtonBorder (Nlm_ButtoN b)
152 {
153   Nlm_ButtonData  bdata;
154 
155   Nlm_GetButtonData (b, &bdata);
156   return bdata.border;
157 }
158 
159 
160 static Nlm_Boolean Nlm_CommonPtInRect (Nlm_GraphiC b, Nlm_PoinT pt)
161 
162 {
163   Nlm_RecT  r;
164 
165   Nlm_GetRect (b, &r);
166   return (Nlm_PtInRect (pt, &r));
167 }
168 
169 static Nlm_Boolean Nlm_CommonButtonClick (Nlm_GraphiC b, Nlm_PoinT pt, Nlm_Int2 part)
170 
171 {
172   Nlm_ControlTool  c;
173   Nlm_PointTool    ptool;
174 
175   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
176   Nlm_PoinTToPointTool (pt, &ptool);
177   return (part == TrackControl (c, ptool, NULL));
178 }
179 
180 static Nlm_Boolean Nlm_PushClick (Nlm_GraphiC b, Nlm_PoinT pt)
181 
182 {
183   Nlm_Boolean  rsult;
184 
185   rsult = FALSE;
186   if (Nlm_CommonPtInRect (b, pt)) {
187     if (Nlm_CommonButtonClick (b, pt, kControlButtonPart)) {
188       Nlm_DoAction (b);
189     }
190     rsult = TRUE;
191   }
192   return rsult;
193 }
194 
195 static Nlm_Boolean Nlm_DefaultClick (Nlm_GraphiC b, Nlm_PoinT pt)
196 
197 {
198   Nlm_Boolean  rsult;
199 
200   rsult = FALSE;
201   if (Nlm_CommonPtInRect (b, pt)) {
202     if (Nlm_CommonButtonClick (b, pt, kControlButtonPart)) {
203       Nlm_DoAction (b);
204     }
205     rsult = TRUE;
206   }
207   return rsult;
208 }
209 
210 static Nlm_Boolean Nlm_CheckClick (Nlm_GraphiC b, Nlm_PoinT pt)
211 
212 {
213   Nlm_Boolean  _bool_;
214   Nlm_GraphiC  g;
215   Nlm_Boolean  rsult;
216 
217   rsult = FALSE;
218   if (Nlm_CommonPtInRect (b, pt)) {
219     if (Nlm_CommonButtonClick (b, pt, kControlCheckBoxPart)) {
220       _bool_ = Nlm_DoGetStatus (b, 0);
221       if (_bool_) {
222         Nlm_DoSetStatus (b, 0, FALSE, FALSE);
223       } else {
224         Nlm_DoSetStatus (b, 0, TRUE, FALSE);
225       }
226       Nlm_DoAction (b);
227       g = Nlm_GetParent (b);
228       Nlm_DoAction (g);
229     }
230     rsult = TRUE;
231   }
232   return rsult;
233 }
234 
235 static Nlm_Boolean Nlm_RadioClick (Nlm_GraphiC b, Nlm_PoinT pt)
236 
237 {
238   Nlm_Boolean  _bool_;
239   Nlm_GraphiC  g;
240   Nlm_Boolean  rsult;
241 
242   rsult = FALSE;
243   if (Nlm_CommonPtInRect (b, pt)) {
244     if (Nlm_CommonButtonClick (b, pt, kControlCheckBoxPart)) {
245       _bool_ = Nlm_DoGetStatus (b, 0);
246       if (! _bool_) {
247         g = Nlm_GetParent (b);
248         Nlm_ClearItemsInGroup (g, b, FALSE);
249         Nlm_DoSetStatus (b, 0, TRUE, FALSE);
250         Nlm_DoAction (b);
251         Nlm_DoAction (g);
252       }
253     }
254     rsult = TRUE;
255   }
256   return rsult;
257 }
258 #endif
259 
260 #ifdef WIN_MSWIN
261 static Nlm_Boolean Nlm_PushCommand (Nlm_GraphiC b)
262 
263 {
264   Nlm_DoAction (b);
265   return TRUE;
266 }
267 
268 static Nlm_Boolean Nlm_DefaultCommand (Nlm_GraphiC b)
269 
270 {
271   Nlm_DoAction (b);
272   return TRUE;
273 }
274 
275 static Nlm_Boolean Nlm_CheckCommand (Nlm_GraphiC b)
276 
277 {
278   Nlm_Boolean  _bool_;
279   Nlm_GraphiC  g;
280 
281   _bool_ = Nlm_DoGetStatus (b, 0);
282   if (_bool_) {
283     Nlm_DoSetStatus (b, 0, FALSE, FALSE);
284   } else {
285     Nlm_DoSetStatus (b, 0, TRUE, FALSE);
286   }
287   Nlm_DoAction (b);
288   g = Nlm_GetParent (b);
289   Nlm_DoAction (g);
290   return TRUE;
291 }
292 
293 static Nlm_Boolean Nlm_RadioCommand (Nlm_GraphiC b)
294 
295 {
296   Nlm_Boolean  _bool_;
297   Nlm_GraphiC  g;
298 
299   _bool_ = Nlm_DoGetStatus (b, 0);
300   if (! _bool_) {
301     g = Nlm_GetParent (b);
302     Nlm_ClearItemsInGroup (g, b, FALSE);
303     Nlm_DoSetStatus (b, 0, TRUE, FALSE);
304     Nlm_DoAction (b);
305     Nlm_DoAction (g);
306   }
307   return TRUE;
308 }
309 #endif
310 
311 #ifdef WIN_MOTIF
312 static void Nlm_PushCallback (Nlm_GraphiC b)
313 
314 {
315   Nlm_DoAction (b);
316 }
317 
318 static void Nlm_DefaultCallback (Nlm_GraphiC b)
319 
320 {
321   Nlm_DoAction (b);
322 }
323 
324 static void Nlm_CheckCallback (Nlm_GraphiC b)
325 
326 {
327   Nlm_Boolean      _bool_;
328   Nlm_ControlTool  c;
329   Nlm_GraphiC      g;
330 
331   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
332   _bool_ = Nlm_DoGetStatus (b, 0);
333   if (! _bool_) {
334     Nlm_DoSetStatus (b, 0, FALSE, FALSE);
335   } else {
336     Nlm_DoSetStatus (b, 0, TRUE, FALSE);
337   }
338   Nlm_DoAction (b);
339   g = Nlm_GetParent (b);
340   Nlm_DoAction (g);
341 }
342 
343 static void Nlm_RadioCallback (Nlm_GraphiC b)
344 
345 {
346   Nlm_Boolean      _bool_;
347   Nlm_ControlTool  c;
348   Nlm_GraphiC      g;
349 
350   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
351   _bool_ = Nlm_DoGetStatus (b, 0);
352   if (_bool_) {
353     g = Nlm_GetParent (b);
354     Nlm_ClearItemsInGroup (g, b, FALSE);
355     Nlm_DoSetStatus (b, 0, TRUE, FALSE);
356     Nlm_DoAction (b);
357     Nlm_DoAction (g);
358   } else {
359     Nlm_DoSetStatus (b, 0, TRUE, FALSE);
360   }
361 }
362 #endif
363 
364 #ifdef WIN_MAC
365 static Nlm_Boolean Nlm_DefaultKey (Nlm_GraphiC b, Nlm_Char ch)
366 
367 {
368   Nlm_ControlTool  c;
369   unsigned long    res;
370   Nlm_Boolean      rsult;
371 
372   rsult = FALSE;
373   if (ch == '\15' || ch == '\3') {
374     c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
375     HiliteControl (c, 1);
376     Delay (8, &res);
377     HiliteControl (c, 0);
378     Nlm_DoSetStatus (b, 0, TRUE, FALSE);
379     Nlm_DoAction (b);
380     rsult = TRUE;
381   }
382   return rsult;
383 }
384 
385 static void Nlm_DrawButton (Nlm_GraphiC b)
386 
387 {
388   Nlm_ControlTool  c;
389   Nlm_RecT         r;
390 
391   if (Nlm_GetVisible (b) && Nlm_GetAllParentsVisible (b)) {
392     Nlm_GetRect (b, &r);
393     if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
394       c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
395       Draw1Control (c);
396     }
397   }
398 }
399 
400 static void Nlm_DrawDefault (Nlm_GraphiC b)
401 
402 {
403   Nlm_ControlTool  c;
404   Nlm_RecT         r;
405 
406   if (Nlm_HasAquaMenuLayout ()) {
407     Nlm_DrawButton (b);
408     return;
409   }
410   if (Nlm_GetVisible (b) && Nlm_GetAllParentsVisible (b)) {
411     Nlm_GetRect (b, &r);
412     Nlm_InsetRect (&r, -4, -4);
413     if (Nlm_RectInRgn (&r, Nlm_updateRgn)) {
414       Nlm_SetPenWidth (3);
415       Nlm_FrameRoundRect (&r, 16, 16);
416       Nlm_SetPenWidth (1);
417       c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
418       Draw1Control (c);
419     }
420   }
421 }
422 #endif
423 
424 static void Nlm_ShowButton (Nlm_GraphiC b, Nlm_Boolean setFlag, Nlm_Boolean savePort)
425 
426 {
427   Nlm_ControlTool  c;
428   Nlm_WindoW       tempPort;
429 
430   if (setFlag) {
431     Nlm_SetVisible (b, TRUE);
432   }
433   if (Nlm_GetVisible (b) && Nlm_AllParentsButWindowVisible (b)) {
434     tempPort = Nlm_SavePortIfNeeded (b, savePort);
435     c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
436 #ifdef WIN_MAC
437     ShowControl (c);
438     Nlm_DoDraw (b);
439 #endif
440 #ifdef WIN_MSWIN
441     ShowWindow (c, SW_SHOW);
442     UpdateWindow (c);
443 #endif
444 #ifdef WIN_MOTIF
445     XtManageChild (c);
446 #endif
447     Nlm_RestorePort (tempPort);
448   }
449 }
450 
451 static void Nlm_HideButton (Nlm_GraphiC b, Nlm_Boolean setFlag, Nlm_Boolean savePort)
452 
453 {
454   Nlm_ControlTool  c;
455   Nlm_WindoW       tempPort;
456 #ifdef WIN_MAC
457   Nlm_Int2         border;
458   Nlm_RecT         r;
459 #endif
460 
461   if (setFlag) {
462     Nlm_SetVisible (b, FALSE);
463   }
464   tempPort = Nlm_SavePortIfNeeded (b, savePort);
465   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
466 #ifdef WIN_MAC
467   border = Nlm_GetButtonBorder ((Nlm_ButtoN) b);
468   HideControl (c);
469   if (Nlm_GetAllParentsVisible (b)) {
470     Nlm_GetRect (b, &r);
471     Nlm_InsetRect (&r, -1 - border, -1 - border);
472     Nlm_EraseRect (&r);
473     Nlm_ValidRect (&r);
474   }
475 #endif
476 #ifdef WIN_MSWIN
477   ShowWindow (c, SW_HIDE);
478   UpdateWindow (c);
479 #endif
480 #ifdef WIN_MOTIF
481   XtUnmanageChild (c);
482 #endif
483   Nlm_RestorePort (tempPort);
484 }
485 
486 static void Nlm_EnableButton (Nlm_GraphiC b, Nlm_Boolean setFlag, Nlm_Boolean savePort)
487 
488 {
489   Nlm_ControlTool  c;
490   Nlm_WindoW       tempPort;
491 
492   if (setFlag) {
493     Nlm_SetEnabled (b, TRUE);
494   }
495   if (Nlm_GetEnabled (b) && Nlm_GetAllParentsEnabled (b)) {
496     tempPort = Nlm_SavePortIfNeeded (b, savePort);
497     c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
498 #ifdef WIN_MAC
499     ActivateControl (c);
500 #endif
501 #ifdef WIN_MSWIN
502     EnableWindow (c, TRUE);
503 #endif
504 #ifdef WIN_MOTIF
505     XtVaSetValues (c, XmNsensitive, TRUE, NULL);
506 #endif
507     Nlm_RestorePort (tempPort);
508   }
509 }
510 
511 static void Nlm_DisableButton (Nlm_GraphiC b, Nlm_Boolean setFlag, Nlm_Boolean savePort)
512 
513 {
514   Nlm_ControlTool  c;
515   Nlm_WindoW       tempPort;
516 
517   if (setFlag) {
518     Nlm_SetEnabled (b, FALSE);
519   }
520   tempPort = Nlm_SavePortIfNeeded (b, savePort);
521   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
522 #ifdef WIN_MAC
523   DeactivateControl (c);
524 #endif
525 #ifdef WIN_MSWIN
526   EnableWindow (c, FALSE);
527 #endif
528 #ifdef WIN_MOTIF
529   XtVaSetValues (c, XmNsensitive, FALSE, NULL);
530 #endif
531   Nlm_RestorePort (tempPort);
532 }
533 
534 static void Nlm_RemoveButton (Nlm_GraphiC b, Nlm_Boolean savePort)
535 
536 {
537   Nlm_ControlTool  c;
538   Nlm_WindoW       tempPort;
539 
540   tempPort = Nlm_SavePortIfNeeded (b, savePort);
541   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
542 #ifdef WIN_MAC
543   DisposeControl (c);
544 #endif
545 #ifdef WIN_MSWIN
546   RemoveProp (c, (LPSTR) "Nlm_VibrantProp");
547   DestroyWindow (c);
548 #endif
549 #ifdef WIN_MOTIF
550   XtDestroyWidget (c);
551 #endif
552   Nlm_RemoveLink (b);
553   recentButton = NULL;
554   Nlm_RestorePort (tempPort);
555 }
556 
557 static void Nlm_RemoveDefaultButton (Nlm_GraphiC b, Nlm_Boolean savePort)
558 
559 {
560   Nlm_ControlTool  c;
561   Nlm_WindoW       tempPort;
562 #ifdef WIN_MOTIF
563   Nlm_WindoW       w;
564   Nlm_WindowTool   wptr;
565 #endif
566 
567   tempPort = Nlm_SavePortIfNeeded (b, savePort);
568   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
569 #ifdef WIN_MAC
570   DisposeControl (c);
571 #endif
572 #ifdef WIN_MSWIN
573   RemoveProp (c, (LPSTR) "Nlm_VibrantProp");
574   DestroyWindow (c);
575 #endif
576 #ifdef WIN_MOTIF
577   w = Nlm_ParentWindow (b);
578   wptr = Nlm_ParentWindowPtr (b);
579   if (Nlm_GetWindowDefaultButton (w) == (Nlm_ButtoN) b) {
580     Nlm_SetWindowDefaultButton (w, NULL);
581 #ifndef LESSTIF_VERSION
582     /* causes segfault using LessTif (0.89) under RH Linux 6 */
583     XtVaSetValues (wptr, XmNdefaultButton, NULL, NULL);
584 #endif
585     {{
586       Widget shell = Nlm_ParentWindowShell((Nlm_GraphiC) b);
587       Atom atom =XmInternAtom(Nlm_currentXDisplay, "WM_TAKE_FOCUS", TRUE);
588       if ( atom )
589         XmRemoveWMProtocolCallback(shell, atom,
590                                    NlmHint_ResetDefButtonA,
591                                    (XtPointer) b);
592       XtRemoveEventHandler(shell, FocusChangeMask, FALSE,
593                            NlmHint_ResetDefButtonE, (XtPointer)b);
594     }}
595   }
596   XtDestroyWidget (c);
597 #endif
598   Nlm_RemoveLink (b);
599   recentButton = NULL;
600   Nlm_RestorePort (tempPort);
601 }
602 
603 static void Nlm_SetButtonTitle (Nlm_GraphiC b, Nlm_Int2 item,
604                                 Nlm_CharPtr title, Nlm_Boolean savePort)
605 
606 {
607   Nlm_ControlTool  c;
608   Nlm_Char         temp [256];
609   Nlm_WindoW       tempPort;
610 #ifdef WIN_MOTIF
611   XmString         label;
612 #endif
613 
614   tempPort = Nlm_SavePortIfNeeded (b, savePort);
615   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
616   Nlm_StringNCpy_0 (temp, title, sizeof (temp));
617 #ifdef WIN_MAC
618   Nlm_CtoPstr (temp);
619   SetControlTitle (c, (StringPtr) temp);
620 #endif
621 #ifdef WIN_MSWIN
622   SetWindowText (c, temp);
623 #endif
624 #ifdef WIN_MOTIF
625   label = XmStringCreateSimple (temp);
626   XtVaSetValues (c, XmNlabelString, label, NULL);
627   XmStringFree (label);
628 #endif
629   Nlm_RestorePort (tempPort);
630 }
631 
632 static void Nlm_GetButtonTitle (Nlm_GraphiC b, Nlm_Int2 item,
633                                 Nlm_CharPtr title, size_t maxsize)
634 
635 {
636   Nlm_ControlTool  c;
637   Nlm_Char         temp [256];
638 #ifdef WIN_MOTIF
639   XmString         label;
640   char             *text;
641 #endif
642 
643   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
644 #ifdef WIN_MAC
645   GetControlTitle (c, (StringPtr) temp);
646   Nlm_PtoCstr (temp);
647 #endif
648 #ifdef WIN_MSWIN
649   GetWindowText (c, temp, sizeof (temp));
650 #endif
651 #ifdef WIN_MOTIF
652   XtVaGetValues (c, XmNlabelString, &label, NULL);
653   temp [0] = '\0';
654   if (XmStringGetLtoR (label, XmSTRING_DEFAULT_CHARSET, &text)) {
655     Nlm_StringNCpy_0 (temp, text, sizeof (temp));
656     XtFree (text);
657   }
658 #endif
659   Nlm_StringNCpy_0 (title, temp, maxsize);
660 }
661 
662 static void Nlm_SetButtonStatus (Nlm_GraphiC b, Nlm_Int2 item,
663                                  Nlm_Boolean set, Nlm_Boolean savePort)
664 
665 {
666   Nlm_ControlTool  c;
667   Nlm_WindoW       tempPort;
668   Nlm_Int2         val;
669 
670   tempPort = Nlm_SavePortIfNeeded (b, savePort);
671   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
672   if (set) {
673     val = 1;
674   } else {
675     val = 0;
676   }
677 #ifdef WIN_MAC
678   SetControl32BitValue (c, val);
679 #endif
680 #ifdef WIN_MSWIN
681   Button_SetCheck (c, val);
682 #endif
683 #ifdef WIN_MOTIF
684   XmToggleButtonSetState (c, (Boolean) set, FALSE);
685 #endif
686   Nlm_RestorePort (tempPort);
687 }
688 
689 static Nlm_Boolean Nlm_GetButtonStatus (Nlm_GraphiC b, Nlm_Int2 item)
690 
691 {
692   Nlm_ControlTool  c;
693 
694   c = Nlm_GetButtonHandle ((Nlm_ButtoN) b);
695 #ifdef WIN_MAC
696   return (GetControl32BitValue (c) != 0);
697 #endif
698 #ifdef WIN_MSWIN
699   return (Nlm_Boolean) (Button_GetCheck (c) != 0);
700 #endif
701 #ifdef WIN_MOTIF
702   return (Nlm_Boolean) (XmToggleButtonGetState (c) != FALSE);
703 #endif
704 }
705 
706 #ifdef WIN_MAC
707 static void Nlm_InvalButton (Nlm_GraphiC b, Nlm_Int2 border)
708 
709 {
710   Nlm_RecT  r;
711 
712   if (Nlm_GetVisible (b) && Nlm_GetAllParentsVisible (b)) {
713     Nlm_GetRect (b, &r);
714     Nlm_InsetRect (&r, -1 - border, -1 - border);
715     Nlm_InvalRect (&r);
716   }
717 }
718 #endif
719 
720 static void Nlm_SetButtonPosition (Nlm_GraphiC b, Nlm_RectPtr r, Nlm_Boolean savePort, Nlm_Boolean force)
721 
722 {
723   Nlm_ButtonData   bdata;
724   Nlm_ControlTool  c;
725   Nlm_RecT         oldRect;
726   Nlm_WindoW       tempPort;
727 #ifdef WIN_MAC
728   Nlm_Int2         border;
729 #endif
730 
731   if (r == NULL)  return;
732 
733   if ( !Nlm_GetRealized( b ) )
734     {
735       Nlm_SetRect(b, r);
736       return;
737     }
738 
739   Nlm_DoGetPosition (b, &oldRect);
740   if (!force  &&  Nlm_EqualRect(r, &oldRect))  return;
741 
742   tempPort = Nlm_SavePortIfNeeded (b, savePort);
743   Nlm_GetButtonData ((Nlm_ButtoN) b, &bdata);
744   c = bdata.handle;
745 #ifdef WIN_MAC
746   border = bdata.border;
747   Nlm_InvalButton (b, border);
748   MoveControl (c, r->left, r->top);
749   SizeControl (c, r->right - r->left - bdata.shrinkX, r->bottom - r->top - bdata.shrinkY);
750   Nlm_SetRect (b, r);
751   Nlm_InvalButton (b, border);
752 #endif
753 #ifdef WIN_MSWIN
754   MoveWindow(c, r->left, r->top, r->right - r->left, r->bottom - r->top, TRUE);
755   Nlm_SetRect (b, r);
756   UpdateWindow (c);
757 #endif
758 #ifdef WIN_MOTIF
759   {{
760     Nlm_Int2 offset = bdata.offset;
761     XtVaSetValues (c,
762                    XmNx, (Position) (r->left - offset),
763                    XmNy, (Position) (r->top  - offset),
764                    XmNwidth,  (Dimension) (r->right  - r->left),
765                    XmNheight, (Dimension) (r->bottom - r->top), 
766                    NULL);
767   }}
768   Nlm_SetRect (b, r);
769 #endif
770 
771   Nlm_RestorePort (tempPort);
772 }
773 
774 static void Nlm_GetButtonPosition (Nlm_GraphiC b, Nlm_RectPtr r)
775 
776 {
777   if (r != NULL) {
778     Nlm_GetRect (b, r);
779   }
780 }
781 
782 static Nlm_GraphiC Nlm_DefaultGainFocus (Nlm_GraphiC b, Nlm_Char ch, Nlm_Boolean savePort)
783 
784 {
785 #ifdef WIN_MAC
786   return NULL;
787 #endif
788 #ifdef WIN_MSWIN
789   Nlm_GraphiC   rsult;
790 
791   rsult = NULL;
792   if (ch == '\n' || ch == '\r') {
793     if (Nlm_GetVisible (b) && Nlm_GetAllParentsVisible (b) &&
794         Nlm_GetEnabled (b) && Nlm_GetAllParentsEnabled (b)) {
795       Nlm_DoAction (b);
796       rsult = b;
797     }
798   }
799   return rsult;
800 #endif
801 #ifdef WIN_MOTIF
802   return NULL;
803 #endif
804 }
805 
806 
807 #ifdef WIN_MSWIN
808 static Nlm_Boolean Nlm_IsDefaultButton (Nlm_ButtoN b)
809 {
810   Nlm_ButtonData  bdata;
811   Nlm_GetButtonData (b, &bdata);
812   return bdata.defaultBtn;
813 }
814 
815 /* Message cracker functions */
816 
817 static void MyCls_OnChar (HWND hwnd, UINT ch, int cRepeat)
818 
819 {
820   Nlm_ButtoN  b;
821 
822   b = (Nlm_ButtoN) GetProp (hwnd, (LPSTR) "Nlm_VibrantProp");
823   handlechar = FALSE;
824   if (ch == '\t') {
825     Nlm_DoSendFocus ((Nlm_GraphiC) b, (Nlm_Char) ch);
826   } else if (ch == '\n' || ch == '\r') {
827     if (Nlm_IsDefaultButton (b)) {
828       Nlm_DoGainFocus ((Nlm_GraphiC) b, (Nlm_Char) ch, FALSE);
829     } else {
830       Nlm_DoSendFocus ((Nlm_GraphiC) b, (Nlm_Char) ch);
831     }
832   } else {
833     handlechar = TRUE;
834   }
835 }
836 
837 static LRESULT CALLBACK EXPORT ButtonProc (HWND hwnd, UINT message,
838                                     WPARAM wParam, LPARAM lParam)
839 
840 {
841   Nlm_ButtoN  b;
842   BOOL        call_win_proc = TRUE;
843   LRESULT     rsult = 0;
844   HDC         tempHDC;
845   HWND        tempHWnd;
846 
847   if (Nlm_VibrantDisabled ()) {
848     return CallWindowProc (lpfnOldButtonProc, hwnd, message, wParam, lParam);
849   }
850 
851   tempHWnd = Nlm_currentHWnd;
852   tempHDC = Nlm_currentHDC;
853   b = (Nlm_ButtoN) GetProp (hwnd, (LPSTR) "Nlm_VibrantProp");
854   Nlm_theWindow = Nlm_GetParentWindow ((Nlm_GraphiC) b);
855   Nlm_currentHWnd = GetParent (hwnd);
856   Nlm_currentHDC = Nlm_ParentWindowPort ((Nlm_GraphiC) b);
857   Nlm_currentWindowTool = hwnd;
858   Nlm_currentKey = '\0';
859   Nlm_currentWParam = wParam;
860   Nlm_currentLParam = lParam;
861   Nlm_cmmdKey  = FALSE;
862   Nlm_ctrlKey  = FALSE;
863   Nlm_optKey   = FALSE;
864   Nlm_shftKey  = FALSE;
865   Nlm_dblClick = FALSE;
866 
867   switch (message) {
868     case WM_KEYDOWN:
869       call_win_proc = !Nlm_ProcessKeydown((Nlm_GraphiC)b, wParam,
870                                VERT_PAGE|VERT_ARROW|HORIZ_PAGE|HORIZ_ARROW);
871       break;
872     case WM_CHAR:
873       HANDLE_WM_CHAR (hwnd, wParam, lParam, MyCls_OnChar);
874       call_win_proc = handlechar;
875       break;
876   }
877 
878   if ( call_win_proc )
879     rsult = CallWindowProc(lpfnOldButtonProc, hwnd, message, wParam, lParam);
880 
881   Nlm_currentHWnd = tempHWnd;
882   Nlm_currentHDC  = tempHDC;
883   Nlm_currentWindowTool = tempHWnd;
884   return rsult;
885 }
886 
887 
888 static void Nlm_PrepareTitleMsWin(Nlm_CharPtr temp, Nlm_CharPtr title,
889                                   size_t siztemp)
890 {
891     /* duplicate existing '&' */
892     Nlm_Uint4 src_pos = 0;
893     Nlm_Uint4 dest_pos = 0;
894 
895     for(src_pos = 0, dest_pos = 0;
896         title[src_pos] != '\0' && dest_pos+1 < siztemp;
897         ++src_pos)
898     {
899         if(title[src_pos] == '&')
900         {
901             if(dest_pos + 2 < siztemp)
902             {
903                 temp[dest_pos++] = '&';
904                 temp[dest_pos++] = title[src_pos];
905             }
906             else
907                 break;
908         }
909         else
910             temp[dest_pos++] = title[src_pos];
911     }
912 
913     temp[dest_pos] = '\0';
914 }
915 #endif
916 
917 #ifdef WIN_MOTIF
918 static void Nlm_ButtonCallback (Widget w, XtPointer client_data, XtPointer call_data)
919 
920 {
921   Nlm_GraphiC  b;
922 
923   b = (Nlm_GraphiC) client_data;
924   Nlm_DoCallback (b);
925 }
926 
927 extern void Nlm_MapDefaultButton (Nlm_WindoW w, Nlm_ButtoN b)
928 
929 {
930   Nlm_ControlTool  c;
931   Nlm_WindowTool   wptr;
932 
933   if (w != NULL && b != NULL) {
934     wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) b);
935     c = Nlm_GetButtonHandle (b);
936     Nlm_SetWindowDefaultButton (w, b);
937     XtVaSetValues (wptr, XmNdefaultButton, c, NULL);
938   }
939 }
940 #endif
941 
942 
943 #define PUSH_STYLE 1
944 #define DEFAULT_STYLE 2
945 #define CHECK_STYLE 3
946 #define RADIO_STYLE 4
947 
948 #ifdef WIN_MOTIF
949 static void NlmHint_ResetDefButton(Nlm_ButtoN b)
950 {
951   Nlm_WindowTool  wptr  = Nlm_ParentWindowPtr((Nlm_GraphiC) b);
952   Nlm_ControlTool bptr  = Nlm_GetButtonHandle( b );
953 
954   XtVaSetValues(wptr, XmNdefaultButton, NULL, NULL);
955   XtVaSetValues(wptr, XmNdefaultButton, bptr, NULL);
956 }
957 
958 static void NlmHint_ResetDefButtonE(Widget w, XtPointer client_data,
959                                    XEvent *event,
960                                    Boolean *continue_to_dispatch )
961 {
962   if (event->type == FocusIn)
963     NlmHint_ResetDefButton( (Nlm_ButtoN)client_data );
964 }
965 
966 static void NlmHint_ResetDefButtonA(Widget w, XtPointer client_data,
967                                     XtPointer call_data)
968 {
969   NlmHint_ResetDefButton( (Nlm_ButtoN)client_data );
970 }
971 #endif
972 
973 
974 static void Nlm_NewButton (Nlm_ButtoN b, Nlm_CharPtr title,
975                            Nlm_Int2 type, Nlm_Int2 shrinkX,
976                            Nlm_Int2 shrinkY, Nlm_BtnActnProc actn)
977 {
978   Nlm_Int2         border;
979   Nlm_ControlTool  c;
980   Nlm_Boolean      dflt;
981   Nlm_Int2         offset;
982   Nlm_RecT         r;
983   Nlm_Char         temp [256];
984   Nlm_WindowTool   wptr;
985 #ifdef WIN_MAC
986   Nlm_Int2         procID;
987   Nlm_RectTool     rtool;
988   CFStringRef      cfTitle;
989 #endif
990 #ifdef WIN_MSWIN
991   Nlm_Uint4        style;
992   Nlm_FntPtr fntptr;
993 #endif
994 #ifdef WIN_MOTIF
995   String           call;
996   XmString         label;
997   Cardinal         n;
998   Arg              wargs [15];
999 #endif
1000 
1001   Nlm_GetRect ((Nlm_GraphiC) b, &r);
1002   wptr = Nlm_ParentWindowPtr ((Nlm_GraphiC) b);
1003 #ifdef WIN_MSWIN
1004   Nlm_PrepareTitleMsWin (temp, title, sizeof (temp));
1005 #else
1006   Nlm_StringNCpy_0 (temp, title, sizeof (temp));
1007 #endif
1008   c = (Nlm_ControlTool) 0;
1009   border = 0;
1010   offset = 0;
1011   dflt = (Nlm_Boolean) (type == DEFAULT_STYLE);
1012 
1013 #ifdef WIN_MAC
1014   cfTitle = CFStringCreateWithCString(NULL, temp, kCFStringEncodingMacRoman);
1015   switch (type) {
1016     case DEFAULT_STYLE:
1017       if (! Nlm_HasAquaMenuLayout ()) {
1018         border = 5;
1019       }
1020       /* fall through */
1021     case PUSH_STYLE:
1022       r.right -= shrinkX;
1023       r.bottom -= shrinkY;
1024       Nlm_RecTToRectTool (&r, &rtool);
1025       CreatePushButtonControl(wptr, &rtool, cfTitle, &c);
1026       break;
1027     case CHECK_STYLE:
1028       Nlm_RecTToRectTool (&r, &rtool);
1029       CreateCheckBoxControl(wptr, &rtool, cfTitle, 0, FALSE, &c);
1030       break;
1031     case RADIO_STYLE:
1032       Nlm_RecTToRectTool (&r, &rtool);
1033       CreateRadioButtonControl(wptr, &rtool, cfTitle, 0, FALSE, &c);
1034       break;
1035     default:
1036       procID = 0;
1037       break;
1038   }
1039   Nlm_LoadButtonData (b, c, border, offset, shrinkX, shrinkY, dflt);
1040 #endif
1041 
1042 #ifdef WIN_MSWIN
1043   switch (type) {
1044     case PUSH_STYLE:
1045       style = BS_PUSHBUTTON;
1046       break;
1047     case DEFAULT_STYLE:
1048       style = BS_DEFPUSHBUTTON;
1049       break;
1050     case CHECK_STYLE:
1051       style = BS_CHECKBOX;
1052       break;
1053     case RADIO_STYLE:
1054       style = BS_RADIOBUTTON;
1055       break;
1056     default:
1057       style = BS_PUSHBUTTON;
1058       break;
1059   }
1060   c = CreateWindow ("Button", temp, WS_CHILD | style,
1061                     r.left, r.top, r.right - r.left,
1062                     r.bottom - r.top, wptr, 0,
1063                     Nlm_currentHInst, NULL);
1064   if ( c ) {
1065     SetProp (c, (LPSTR) "Nlm_VibrantProp", (Nlm_HandleTool) b);
1066   }
1067   Nlm_LoadButtonData (b, c, border, offset, 0, 0, dflt);
1068   if (lpfnNewButtonProc == NULL) {
1069     lpfnNewButtonProc = (WNDPROC) MakeProcInstance ((FARPROC) ButtonProc, Nlm_currentHInst);
1070   }
1071   if (lpfnOldButtonProc == NULL) {
1072     lpfnOldButtonProc = (WNDPROC) GetWindowLongPtr (c, GWLP_WNDPROC);
1073   } else if (lpfnOldButtonProc != (WNDPROC) GetWindowLongPtr (c, GWLP_WNDPROC)) {
1074     Nlm_Message (MSG_ERROR, "ButtonProc subclass error");
1075   }
1076   SetWindowLongPtr (c, GWLP_WNDPROC, (LONG) lpfnNewButtonProc);
1077   fntptr = (Nlm_FntPtr) Nlm_HandLock (Nlm_systemFont);
1078   SetWindowFont(c, fntptr->handle, FALSE);
1079   Nlm_HandUnlock(Nlm_systemFont);
1080 #endif
1081 
1082 #ifdef WIN_MOTIF
1083   n = 0;
1084   label = XmStringCreateSimple (temp);
1085   XtSetArg (wargs [n], XmNlabelString, label); n++;
1086 
1087   if (r.right > r.left)
1088     {
1089       XtSetArg (wargs [n], XmNwidth, (Dimension) (r.right - r.left));
1090       n++;
1091     }
1092 
1093   if (r.bottom > r.top)
1094     {
1095       XtSetArg (wargs [n], XmNheight, (Dimension) (r.bottom - r.top));
1096       n++;
1097     }
1098 
1099   if (type == DEFAULT_STYLE  || type == PUSH_STYLE)
1100     {
1101       r.left -= 2;
1102       r.top  -= 4;
1103     }
1104   XtSetArg (wargs [n], XmNx, (Position) r.left - offset);  n++;
1105   XtSetArg (wargs [n], XmNy, (Position) r.top  - offset);  n++;
1106   XtSetArg (wargs [n], XmNborderWidth, (Dimension) 0); n++;
1107   XtSetArg (wargs [n], XmNhighlightThickness, (Dimension) 0); n++;
1108   switch (type) {
1109     case DEFAULT_STYLE:
1110       Nlm_SetWindowDefaultButton(Nlm_ParentWindow((Nlm_GraphiC) b), b);
1111     case PUSH_STYLE:
1112       XtSetArg (wargs [n], XmNrecomputeSize, FALSE); n++;
1113       c = XmCreatePushButton (wptr, (String) "", wargs, n);
1114       XtVaSetValues (wptr, XmNdefaultButton, c, NULL);
1115       call = XmNactivateCallback;
1116       break;
1117     case CHECK_STYLE:
1118       XtSetArg (wargs [n], XmNindicatorType, XmN_OF_MANY); n++;
1119       XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
1120       c = XmCreateToggleButton (wptr, (String) "", wargs, n);
1121       call = XmNvalueChangedCallback;
1122       break;
1123     case RADIO_STYLE:
1124       XtSetArg (wargs [n], XmNindicatorType, XmONE_OF_MANY); n++;
1125       XtSetArg (wargs [n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
1126       c = XmCreateToggleButton (wptr, (String) "", wargs, n);
1127       call = XmNvalueChangedCallback;
1128       break;
1129     default:
1130       break;
1131   }
1132   XmStringFree (label);
1133   XtAddCallback (c, call, Nlm_ButtonCallback, (XtPointer) b);
1134   Nlm_LoadButtonData (b, c, border, offset, 0, 0, dflt);
1135   Nlm_OverrideStdTranslations((Nlm_GraphiC)b, c,
1136                               VERT_PAGE|VERT_ARROW|HORIZ_PAGE|HORIZ_ARROW);
1137   XtManageChild( c );
1138   XtVaGetValues(c, XmNwidth, &r.right, XmNheight, &r.bottom, NULL);
1139   r.right  += r.left;
1140   r.bottom += r.top;
1141   Nlm_SetRect((Nlm_GraphiC)b, &r);
1142   switch ( type )
1143     {
1144     case DEFAULT_STYLE:
1145       {
1146         Atom atom = XmInternAtom(Nlm_currentXDisplay, "WM_TAKE_FOCUS",
1147                                  TRUE);
1148         Widget shell = Nlm_ParentWindowShell((Nlm_GraphiC) b);
1149         if ( atom )
1150           XmAddWMProtocolCallback(shell, atom,
1151                                   NlmHint_ResetDefButtonA, (XtPointer) b);
1152         XtAddEventHandler(shell,
1153                           FocusChangeMask, FALSE,
1154                           NlmHint_ResetDefButtonE, (XtPointer) b);
1155       }
1156     case PUSH_STYLE:
1157       XtVaSetValues(wptr, XmNdefaultButton, NULL, NULL);
1158       break;
1159     }
1160 #endif
1161 
1162   Nlm_LoadAction ((Nlm_GraphiC) b, (Nlm_ActnProc) actn);
1163 }
1164 
1165 
1166 static Nlm_ButtoN Nlm_CommonButton (Nlm_GrouP prnt, Nlm_CharPtr title,
1167                                     Nlm_Int2 type, Nlm_BtnActnProc actn,
1168                                     Nlm_GphPrcsPtr classPtr)
1169 
1170 {
1171   Nlm_ButtoN  b = NULL;
1172   Nlm_Int2    hgt;
1173   Nlm_PoinT   npt;
1174   Nlm_RecT    r;
1175   Nlm_Int2    shrinkX = 0;
1176   Nlm_Int2    shrinkY = 0;
1177   Nlm_WindoW  tempPort;
1178   Nlm_Int2    wid;
1179 
1180   if (prnt == NULL)  return NULL;
1181 
1182   tempPort = Nlm_SavePort ((Nlm_GraphiC) prnt);
1183   Nlm_GetNextPosition ((Nlm_GraphiC) prnt, &npt);
1184   Nlm_SelectFont (Nlm_systemFont);
1185   wid = Nlm_StringWidth (title);
1186 
1187 #ifdef WIN_MAC
1188   hgt = Nlm_stdLineHeight;
1189   wid += 20;
1190   switch (type) {
1191     case PUSH_STYLE:
1192     case DEFAULT_STYLE:
1193       hgt += 3;
1194       break;
1195   }
1196   if (Nlm_HasAquaMenuLayout ()) {
1197     switch (type) {
1198       case PUSH_STYLE:
1199         wid += 10;
1200         hgt = 26;
1201         shrinkX = 6;
1202         shrinkY = 6;
1203         break;
1204       case DEFAULT_STYLE:
1205         wid += 10;
1206         hgt = 26;
1207         shrinkX = 6;
1208         shrinkY = 6;
1209         break;
1210       case CHECK_STYLE:
1211         wid += 4;
1212         break;
1213       case RADIO_STYLE:
1214         wid += 4;
1215         break;
1216       default:
1217         wid += 0;
1218         break;
1219     }
1220   }
1221 #endif
1222 
1223 #ifdef WIN_MSWIN
1224   switch (type) {
1225     case PUSH_STYLE:
1226       hgt = Nlm_stdLineHeight+8;
1227       wid += 20;
1228       break;
1229     case DEFAULT_STYLE:
1230       hgt = Nlm_stdLineHeight+8;
1231       wid += 20;
1232       break;
1233     case CHECK_STYLE:
1234       hgt = Nlm_stdLineHeight+3;
1235       wid += 20;
1236       break;
1237     case RADIO_STYLE:
1238       hgt = Nlm_stdLineHeight+3;
1239       wid += 20;
1240       break;
1241     default:
1242       hgt = Nlm_stdLineHeight;
1243       wid += 20;
1244       break;
1245   }
1246 #endif
1247 
1248 #ifdef WIN_MOTIF
1249   hgt = 0;
1250   wid = 0;
1251 #endif
1252 
1253   Nlm_LoadRect(&r, npt.x, npt.y, (Nlm_Int2)(npt.x+wid), (Nlm_Int2)(npt.y+hgt));
1254   b = (Nlm_ButtoN) Nlm_CreateLink ((Nlm_GraphiC) prnt, &r, sizeof (Nlm_ButtonRec), classPtr);
1255   if (b != NULL) {
1256     Nlm_NewButton (b, title, type, shrinkX, shrinkY, actn);
1257     Nlm_GetRect ((Nlm_GraphiC) b, &r);
1258     Nlm_DoAdjustPrnt ((Nlm_GraphiC) b, &r, TRUE, FALSE);
1259     Nlm_DoShow ((Nlm_GraphiC) b, TRUE, FALSE);
1260   }
1261   Nlm_RestorePort (tempPort);
1262 
1263   return b;
1264 }
1265 
1266 
1267 extern Nlm_ButtoN Nlm_PushButton (Nlm_GrouP prnt, Nlm_CharPtr title,
1268                                   Nlm_BtnActnProc actn)
1269 
1270 {
1271   Nlm_ButtoN  b;
1272 
1273   b = Nlm_CommonButton (prnt, title, PUSH_STYLE, actn, pushProcs);
1274   return b;
1275 }
1276 
1277 extern Nlm_ButtoN Nlm_DefaultButton (Nlm_GrouP prnt, Nlm_CharPtr title,
1278                                      Nlm_BtnActnProc actn)
1279 
1280 {
1281   Nlm_ButtoN  b;
1282 
1283   b = Nlm_CommonButton (prnt, title, DEFAULT_STYLE, actn, defaultProcs);
1284   return b;
1285 }
1286 
1287 extern Nlm_ButtoN Nlm_CheckBox (Nlm_GrouP prnt, Nlm_CharPtr title,
1288                                 Nlm_BtnActnProc actn)
1289 
1290 {
1291   Nlm_ButtoN  b;
1292 
1293   b = Nlm_CommonButton (prnt, title, CHECK_STYLE, actn, checkProcs);
1294   return b;
1295 }
1296 
1297 extern Nlm_ButtoN Nlm_RadioButton (Nlm_GrouP prnt, Nlm_CharPtr title)
1298 
1299 {
1300   Nlm_ButtoN  b;
1301 
1302   b = Nlm_CommonButton (prnt, title, RADIO_STYLE, NULL, radioProcs);
1303   return b;
1304 }
1305 
1306 extern void Nlm_FreeButtons (void)
1307 
1308 {
1309   gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemFree (gphprcsptr);
1310 }
1311 
1312 extern void Nlm_InitButtons (void)
1313 
1314 {
1315   gphprcsptr = (Nlm_GphPrcsPtr) Nlm_MemNew (sizeof (Nlm_GphPrcs) * 4);
1316 
1317   pushProcs = &(gphprcsptr [0]);
1318 #ifdef WIN_MAC
1319   pushProcs->click = Nlm_PushClick;
1320   pushProcs->draw = Nlm_DrawButton;
1321 #endif
1322 #ifdef WIN_MSWIN
1323   pushProcs->command = Nlm_PushCommand;
1324 #endif
1325 #ifdef WIN_MOTIF
1326   pushProcs->callback = Nlm_PushCallback;
1327 #endif
1328   pushProcs->show = Nlm_ShowButton;
1329   pushProcs->hide = Nlm_HideButton;
1330   pushProcs->enable = Nlm_EnableButton;
1331   pushProcs->disable = Nlm_DisableButton;
1332   pushProcs->remove = Nlm_RemoveButton;
1333   pushProcs->setTitle = Nlm_SetButtonTitle;
1334   pushProcs->getTitle = Nlm_GetButtonTitle;
1335   pushProcs->setPosition = Nlm_SetButtonPosition;
1336   pushProcs->getPosition = Nlm_GetButtonPosition;
1337 
1338   defaultProcs = &(gphprcsptr [1]);
1339 #ifdef WIN_MAC
1340   defaultProcs->click = Nlm_DefaultClick;
1341   defaultProcs->key = Nlm_DefaultKey;
1342   defaultProcs->draw = Nlm_DrawDefault;
1343 #endif
1344 #ifdef WIN_MSWIN
1345   defaultProcs->command = Nlm_DefaultCommand;
1346 #endif
1347 #ifdef WIN_MOTIF
1348   defaultProcs->callback = Nlm_DefaultCallback;
1349 #endif
1350   defaultProcs->show = Nlm_ShowButton;
1351   defaultProcs->hide = Nlm_HideButton;
1352   defaultProcs->enable = Nlm_EnableButton;
1353   defaultProcs->disable = Nlm_DisableButton;
1354   defaultProcs->remove = Nlm_RemoveDefaultButton;
1355   defaultProcs->setTitle = Nlm_SetButtonTitle;
1356   defaultProcs->getTitle = Nlm_GetButtonTitle;
1357   defaultProcs->setPosition = Nlm_SetButtonPosition;
1358   defaultProcs->getPosition = Nlm_GetButtonPosition;
1359   defaultProcs->gainFocus = Nlm_DefaultGainFocus;
1360 
1361   checkProcs = &(gphprcsptr [2]);
1362 #ifdef WIN_MAC
1363   checkProcs->click = Nlm_CheckClick;
1364   checkProcs->draw = Nlm_DrawButton;
1365 #endif
1366 #ifdef WIN_MSWIN
1367   checkProcs->command = Nlm_CheckCommand;
1368 #endif
1369 #ifdef WIN_MOTIF
1370   checkProcs->callback = Nlm_CheckCallback;
1371 #endif
1372   checkProcs->show = Nlm_ShowButton;
1373   checkProcs->hide = Nlm_HideButton;
1374   checkProcs->enable = Nlm_EnableButton;
1375   checkProcs->disable = Nlm_DisableButton;
1376   checkProcs->remove = Nlm_RemoveButton;
1377   checkProcs->setTitle = Nlm_SetButtonTitle;
1378   checkProcs->getTitle = Nlm_GetButtonTitle;
1379   checkProcs->setStatus = Nlm_SetButtonStatus;
1380   checkProcs->getStatus = Nlm_GetButtonStatus;
1381   checkProcs->setPosition = Nlm_SetButtonPosition;
1382   checkProcs->getPosition = Nlm_GetButtonPosition;
1383 
1384   radioProcs = &(gphprcsptr [3]);
1385 #ifdef WIN_MAC
1386   radioProcs->click = Nlm_RadioClick;
1387   radioProcs->draw = Nlm_DrawButton;
1388 #endif
1389 #ifdef WIN_MSWIN
1390   radioProcs->command = Nlm_RadioCommand;
1391 #endif
1392 #ifdef WIN_MOTIF
1393   radioProcs->callback = Nlm_RadioCallback;
1394 #endif
1395   radioProcs->show = Nlm_ShowButton;
1396   radioProcs->hide = Nlm_HideButton;
1397   radioProcs->enable = Nlm_EnableButton;
1398   radioProcs->disable = Nlm_DisableButton;
1399   radioProcs->remove = Nlm_RemoveButton;
1400   radioProcs->setTitle = Nlm_SetButtonTitle;
1401   radioProcs->getTitle = Nlm_GetButtonTitle;
1402   radioProcs->setStatus = Nlm_SetButtonStatus;
1403   radioProcs->getStatus = Nlm_GetButtonStatus;
1404   radioProcs->setPosition = Nlm_SetButtonPosition;
1405   radioProcs->getPosition = Nlm_GetButtonPosition;
1406 }
1407 
1408 
1409 extern void Nlm_SetButtonDefault (Nlm_ButtoN b, Nlm_Boolean dflt);
1410 extern void Nlm_SetButtonDefault (Nlm_ButtoN b, Nlm_Boolean dflt)
1411 {
1412   if (b != NULL)
1413     {
1414       Nlm_BtnPtr  bp = (Nlm_BtnPtr) Nlm_HandLock (b);
1415       bp->button.defaultBtn = dflt;
1416       Nlm_HandUnlock (b);
1417     }
1418 }
1419 
1420 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.