home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 215 / DDJ9208.ZIP / DFLT13.ZIP / LISTS.C < prev    next >
Text File  |  1992-07-05  |  3KB  |  127 lines

  1. /* --------------- lists.c -------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. /* ----- set focus to the next sibling ----- */
  6. void SetNextFocus()
  7. {
  8.     if (inFocus != NULL)    {
  9.         WINDOW wnd1 = inFocus, pwnd;
  10.         while (TRUE)    {
  11.             pwnd = GetParent(wnd1);
  12.             if (NextWindow(wnd1) != NULL)
  13.                 wnd1 = NextWindow(wnd1);
  14.             else if (pwnd != NULL)
  15.                 wnd1 = FirstWindow(pwnd);
  16.             if (wnd1 == NULL || wnd1 == inFocus)    {
  17.                 wnd1 = pwnd;
  18.                 break;
  19.             }
  20.             if (GetClass(wnd1) == STATUSBAR || GetClass(wnd1) == MENUBAR)
  21.                 continue;
  22.             if (isVisible(wnd1))
  23.                 break;
  24.         }
  25.         if (wnd1 != NULL)    {
  26.             while (wnd1->childfocus != NULL)
  27.                 wnd1 = wnd1->childfocus;
  28.             if (wnd1->condition != ISCLOSING)
  29.                 SendMessage(wnd1, SETFOCUS, TRUE, 0);
  30.         }
  31.     }
  32. }
  33.  
  34. /* ----- set focus to the previous sibling ----- */
  35. void SetPrevFocus()
  36. {
  37.     if (inFocus != NULL)    {
  38.         WINDOW wnd1 = inFocus, pwnd;
  39.         while (TRUE)    {
  40.             pwnd = GetParent(wnd1);
  41.             if (PrevWindow(wnd1) != NULL)
  42.                 wnd1 = PrevWindow(wnd1);
  43.             else if (pwnd != NULL)
  44.                 wnd1 = LastWindow(pwnd);
  45.             if (wnd1 == NULL || wnd1 == inFocus)    {
  46.                 wnd1 = pwnd;
  47.                 break;
  48.             }
  49.             if (GetClass(wnd1) == STATUSBAR)
  50.                 continue;
  51.             if (isVisible(wnd1))
  52.                 break;
  53.         }
  54.         if (wnd1 != NULL)    {
  55.             while (wnd1->childfocus != NULL)
  56.                 wnd1 = wnd1->childfocus;
  57.             if (wnd1->condition != ISCLOSING)
  58.                 SendMessage(wnd1, SETFOCUS, TRUE, 0);
  59.         }
  60.     }
  61. }
  62.  
  63. /* ------- move a window to the end of its parents list ----- */
  64. void ReFocus(WINDOW wnd)
  65. {
  66.     if (GetParent(wnd) != NULL)    {
  67.         if (!isDerivedFrom(GetParent(wnd), DIALOG))    {
  68.             RemoveWindow(wnd);
  69.             AppendWindow(wnd);
  70.         }
  71.         ReFocus(GetParent(wnd));
  72.     }
  73. }
  74.  
  75. /* ---- remove a window from the linked list ---- */
  76. void RemoveWindow(WINDOW wnd)
  77. {
  78.     if (wnd != NULL)    {
  79.         WINDOW pwnd = GetParent(wnd);
  80.         if (PrevWindow(wnd) != NULL)
  81.             NextWindow(PrevWindow(wnd)) = NextWindow(wnd);
  82.         if (NextWindow(wnd) != NULL)
  83.             PrevWindow(NextWindow(wnd)) = PrevWindow(wnd);
  84.         if (pwnd != NULL)    {
  85.             if (wnd == FirstWindow(pwnd))
  86.                 FirstWindow(pwnd) = NextWindow(wnd);
  87.             if (wnd == LastWindow(pwnd))
  88.                 LastWindow(pwnd) = PrevWindow(wnd);
  89.         }
  90.     }
  91. }
  92.  
  93. /* ---- append a window to the linked list ---- */
  94. void AppendWindow(WINDOW wnd)
  95. {
  96.     if (wnd != NULL)    {
  97.         WINDOW pwnd = GetParent(wnd);
  98.         if (pwnd != NULL)    {
  99.             if (FirstWindow(pwnd) == NULL)
  100.                 FirstWindow(pwnd) = wnd;
  101.             if (LastWindow(pwnd) != NULL)
  102.                 NextWindow(LastWindow(pwnd)) = wnd;
  103.             PrevWindow(wnd) = LastWindow(pwnd);
  104.             LastWindow(pwnd) = wnd;
  105.         }
  106.         NextWindow(wnd) = NULL;
  107.     }
  108. }
  109.  
  110. /* ----- if document windows and statusbar or menubar get the focus,
  111.               pass it on ------- */
  112. void SkipApplicationControls(void)
  113. {
  114.     BOOL EmptyAppl = FALSE;
  115.     int ct = 0;
  116.     while (!EmptyAppl && inFocus != NULL)    {
  117.         CLASS cl = GetClass(inFocus);
  118.         if (cl == MENUBAR || cl == STATUSBAR)    {
  119.             SetPrevFocus();
  120.             EmptyAppl = (cl == MENUBAR && ct++);
  121.         }
  122.         else
  123.             break;
  124.     }
  125. }
  126.  
  127.