home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / dflt20.zip / STATBAR.C < prev    next >
Text File  |  1994-07-28  |  1KB  |  58 lines

  1. /* ---------------- statbar.c -------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. extern char time_string[];
  6.  
  7. int StatusBarProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  8. {
  9.     char *statusbar;
  10.     switch (msg)    {
  11.         case CREATE_WINDOW:
  12.             SendMessage(wnd, CAPTURE_CLOCK, 0, 0);
  13.             break;
  14.         case KEYBOARD:
  15.             if ((int)p1 == CTRL_F4)
  16.                 return TRUE;
  17.             break;
  18.         case PAINT:    
  19.             if (!isVisible(wnd))
  20.                 break;
  21.             statusbar = DFcalloc(1, WindowWidth(wnd)+1);
  22.             memset(statusbar, ' ', WindowWidth(wnd));
  23.             *(statusbar+WindowWidth(wnd)) = '\0';
  24.             strncpy(statusbar+1, "F1=Help", 7);
  25.             if (wnd->text)    {
  26.                 int len = min(strlen(wnd->text), WindowWidth(wnd)-17);
  27.                 if (len > 0)    {
  28.                     int off=(WindowWidth(wnd)-len)/2;
  29.                     strncpy(statusbar+off, wnd->text, len);
  30.                 }
  31.             }
  32.             if (wnd->TimePosted)
  33.                 *(statusbar+WindowWidth(wnd)-8) = '\0';
  34.             else
  35.                 strncpy(statusbar+WindowWidth(wnd)-8, time_string, 9);
  36.             SetStandardColor(wnd);
  37.             PutWindowLine(wnd, statusbar, 0, 0);
  38.             free(statusbar);
  39.             return TRUE;
  40.         case BORDER:
  41.             return TRUE;
  42.         case CLOCKTICK:
  43.             SetStandardColor(wnd);
  44.             PutWindowLine(wnd, (char *)p1, WindowWidth(wnd)-8, 0);
  45.             wnd->TimePosted = TRUE;
  46.             SendMessage(wnd->PrevClock, msg, p1, p2);
  47.             return TRUE;
  48.         case CLOSE_WINDOW:
  49.             SendMessage(wnd, RELEASE_CLOCK, 0, 0);
  50.             break;
  51.         default:
  52.             break;
  53.     }
  54.     return BaseWndProc(STATUSBAR, wnd, msg, p1, p2);
  55. }
  56.  
  57. 
  58.