home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 215 / DDJ9210.ZIP / DFLT14.ZIP / STATBAR.C < prev    next >
Text File  |  1992-03-26  |  1KB  |  53 lines

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