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