home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_01 / wbuttona.c < prev    next >
C/C++ Source or Header  |  1991-03-17  |  2KB  |  108 lines

  1. /* WBUTTONA.C
  2.  *
  3.  *    contains  wbutton_activate () and wbutton_inactivate ()
  4.  *
  5.  *    routines to temporarily acivate and inactivate a button.
  6.  */
  7. #include "wsys.h"
  8.  
  9.  
  10.  
  11. static void W_NEAR do_redraw ( WBUTTON *Bptr, int redraw );
  12.  
  13. #define REDRAW_BUTTON   -1
  14.  
  15.  
  16. void wbutton_inactivate (int uval, int redraw)
  17.     {
  18.     WBUTTON *Bptr;
  19.  
  20.     Bptr = wbutton_getptr ( uval );
  21.  
  22.     if ( (NULL == Bptr) )
  23.         {
  24.         return;
  25.         }
  26.  
  27.     do_redraw ( Bptr, redraw );
  28.  
  29.     Bptr-> Bstyle &= WBTN_ACTIVE;    /* inactivate */
  30.  
  31.     return;    /* wbutton_inactivate () */
  32.     }
  33.  
  34.  
  35.  
  36.  
  37.  
  38. void wbutton_activate ( int uval )
  39.     {
  40.  
  41.     WBUTTON *Bptr;
  42.  
  43.     uval = toupper (uval);
  44.  
  45.  
  46.     for (     Bptr = w0->winbutton;
  47.         Bptr;
  48.         Bptr = Bptr->Bchain )
  49.  
  50.         {
  51.  
  52.         if ( Bptr-> Bval == uval )
  53.             {
  54.  
  55.             do_redraw ( Bptr , REDRAW_BUTTON );
  56.  
  57.  
  58.             break;        /* quit for() loop */
  59.             }
  60.  
  61.  
  62.         }
  63.  
  64.  
  65.     return;        /* wbutton_activate */
  66.     }
  67.  
  68.  
  69.  
  70. static void W_NEAR do_redraw ( WBUTTON *Bptr,  int redraw )
  71.     {
  72.  
  73.     char *save_text;
  74.  
  75.     char new_attr;
  76.  
  77.     save_text = Bptr-> Btext;
  78.  
  79.  
  80.     /* draw button in button attr or in window attr ?
  81.      */
  82.     new_attr = (redraw== REDRAW_BUTTON) ? wbuttonattr : wgetattr ();
  83.  
  84.  
  85.     if ( ! redraw )
  86.         {
  87.         /* need to erase button
  88.          * so setup a 'blank' button.
  89.          */
  90.         Bptr-> Btext = NULL;
  91.         }
  92.     if ( Bptr-> Bstyle & WBTN_BOX )
  93.         {
  94.         /* erase the box first,
  95.          * then shrink the size counters
  96.          * so that wbutton_draw will work
  97.          * in text area only.
  98.          */
  99.         wbutton_frame ( Bptr, NO_BORDER, new_attr);
  100.  
  101.         }
  102.     wbutton_draw ( Bptr, new_attr );
  103.  
  104.  
  105.     Bptr->Btext = save_text;
  106.  
  107.     return;    /* redraw */
  108.     }