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