Merge 14981:15268 from trunk
[reactos.git] / rosapps / lib / dflat32 / helpbox.c
1 /* ------------ helpbox.c ----------- */
2
3 #include "dflat32/dflat.h"
4 #include "dflat32/htree.h"
5
6 extern DBOX HelpBox;
7
8 /* -------- strings of D-Flat classes for calling default
9 help text collections -------- */
10 char *ClassNames[] = {
11 #undef ClassDef
12 #define ClassDef(c,b,p,a) #c,
13 #include "dflat32/classes.h"
14 NULL
15 };
16
17 #define MAXHEIGHT (DfGetScreenHeight()-10)
18
19 /* --------- linked list of help text collections -------- */
20 struct helps {
21 char *hname;
22 char *NextName;
23 char *PrevName;
24 long hptr;
25 int bit;
26 int hheight;
27 int hwidth;
28 DFWINDOW hwnd;
29 struct helps *NextHelp;
30 };
31 static struct helps *FirstHelp;
32 static struct helps *LastHelp;
33 static struct helps *ThisHelp;
34
35 /* --- linked stack of help windows that have beed used --- */
36 struct HelpStack {
37 char *hname;
38 struct HelpStack *PrevStack;
39 };
40 static struct HelpStack *LastStack;
41 static struct HelpStack *ThisStack;
42
43 /* --- linked list of keywords in the current help
44 text collection (listhead is in window) -------- */
45 struct keywords {
46 char *hname;
47 int lineno;
48 int off1, off2, off3;
49 int isDefinition;
50 struct keywords *nextword;
51 struct keywords *prevword;
52 };
53
54 static FILE *helpfp;
55 static char hline [160];
56 static BOOL Helping;
57
58 static void SelectHelp(DFWINDOW, char *);
59 static void ReadHelp(DFWINDOW);
60 static void FindHelp(char *);
61 static void FindHelpWindow(DFWINDOW);
62 static void DisplayDefinition(DFWINDOW, char *);
63 static void BestFit(DFWINDOW, DIALOGWINDOW *);
64
65 /* ------------- CREATE_WINDOW message ------------ */
66 static void CreateWindowMsg(DFWINDOW wnd)
67 {
68 Helping = TRUE;
69 GetClass(wnd) = HELPBOX;
70 InitWindowColors(wnd);
71 if (ThisHelp != NULL)
72 ThisHelp->hwnd = wnd;
73 }
74
75 /* ------------- COMMAND message ------------ */
76 static BOOL CommandMsg(DFWINDOW wnd, PARAM p1)
77 {
78 switch ((int)p1) {
79 case ID_CANCEL:
80 ThisStack = LastStack;
81 while (ThisStack != NULL) {
82 LastStack = ThisStack->PrevStack;
83 if (ThisStack->hname != NULL)
84 free(ThisStack->hname);
85 free(ThisStack);
86 ThisStack = LastStack;
87 }
88 break;
89 case ID_PREV:
90 FindHelpWindow(wnd);
91 if (ThisHelp != NULL)
92 SelectHelp(wnd, ThisHelp->PrevName);
93 return TRUE;
94 case ID_NEXT:
95 FindHelpWindow(wnd);
96 if (ThisHelp != NULL)
97 SelectHelp(wnd, ThisHelp->NextName);
98 return TRUE;
99 case ID_BACK:
100 if (LastStack != NULL) {
101 if (LastStack->PrevStack != NULL) {
102 ThisStack = LastStack->PrevStack;
103 if (LastStack->hname != NULL)
104 free(LastStack->hname);
105 free(LastStack);
106 LastStack = ThisStack;
107 SelectHelp(wnd, ThisStack->hname);
108 }
109 }
110 return TRUE;
111 default:
112 break;
113 }
114 return FALSE;
115 }
116
117 /* ------------- KEYBOARD message ------------ */
118 static BOOL KeyboardMsg(DFWINDOW wnd, PARAM p1)
119 {
120 DFWINDOW cwnd;
121 struct keywords *thisword;
122 static char HelpName[50];
123
124 cwnd = ControlWindow(wnd->extension, ID_HELPTEXT);
125 if (cwnd == NULL || inFocus != cwnd)
126 return FALSE;
127 thisword = cwnd->thisword;
128 switch ((int)p1) {
129 case '\r':
130 if (thisword != NULL) {
131 if (thisword->isDefinition)
132 DisplayDefinition(GetParent(wnd),
133 thisword->hname);
134 else {
135 strncpy(HelpName, thisword->hname,
136 sizeof HelpName);
137 SelectHelp(wnd, HelpName);
138 }
139 }
140 return TRUE;
141 case '\t':
142 if (thisword == NULL)
143 thisword = cwnd->firstword;
144 else {
145 if (thisword->nextword == NULL)
146 thisword = cwnd->firstword;
147 else
148 thisword = thisword->nextword;
149 }
150 break;
151 case SHIFT_HT:
152 if (thisword == NULL)
153 thisword = cwnd->lastword;
154 else {
155 if (thisword->prevword == NULL)
156 thisword = cwnd->lastword;
157 else
158 thisword = thisword->prevword;
159 }
160 break;
161 default:
162 thisword = NULL;
163 break;
164 }
165 if (thisword != NULL) {
166 cwnd->thisword = thisword;
167 if (thisword->lineno < cwnd->wtop ||
168 thisword->lineno >=
169 cwnd->wtop + ClientHeight(cwnd)) {
170 int distance = ClientHeight(cwnd)/2;
171 do {
172 cwnd->wtop = thisword->lineno-distance;
173 distance /= 2;
174 }
175 while (cwnd->wtop < 0);
176 }
177 DfSendMessage(cwnd, PAINT, 0, 0);
178 return TRUE;
179 }
180 return FALSE;
181 }
182
183 /* ---- window processing module for the HELPBOX ------- */
184 int HelpBoxProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
185 {
186 DBOX *db = wnd->extension;
187
188 switch (msg) {
189 case CREATE_WINDOW:
190 CreateWindowMsg(wnd);
191 break;
192 case INITIATE_DIALOG:
193 ReadHelp(wnd);
194 break;
195 case DFM_COMMAND:
196 if (p2 != 0)
197 break;
198 if (CommandMsg(wnd, p1))
199 return TRUE;
200 break;
201 case KEYBOARD:
202 if (WindowMoving)
203 break;
204 if (KeyboardMsg(wnd, p1))
205 return TRUE;
206 break;
207 case CLOSE_WINDOW:
208 if (db != NULL) {
209 if (db->dwnd.title != NULL) {
210 free(db->dwnd.title);
211 db->dwnd.title = NULL;
212 }
213 }
214 FindHelpWindow(wnd);
215 if (ThisHelp != NULL)
216 ThisHelp->hwnd = NULL;
217 Helping = FALSE;
218 break;
219 default:
220 break;
221 }
222 return BaseWndProc(HELPBOX, wnd, msg, p1, p2);
223 }
224
225 /* ----- select a new help window from its name ----- */
226 static void SelectHelp(DFWINDOW wnd, char *hname)
227 {
228 if (hname != NULL) {
229 DFWINDOW pwnd = GetParent(wnd);
230 DfPostMessage(wnd, ENDDIALOG, 0, 0);
231 DfPostMessage(pwnd, DISPLAY_HELP, (PARAM) hname, 0);
232 }
233 }
234
235 /* ---- PAINT message for the helpbox text editbox ---- */
236 static int PaintMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
237 {
238 struct keywords *thisword;
239 int rtn;
240 if (wnd->thisword != NULL) {
241 DFWINDOW pwnd = GetParent(wnd);
242 char *cp;
243 thisword = wnd->thisword;
244 cp = TextLine(wnd, thisword->lineno);
245 cp += thisword->off1;
246 *(cp+1) =
247 (pwnd->WindowColors[SELECT_COLOR][FG] & 255) | 0x80;
248 *(cp+2) =
249 (pwnd->WindowColors[SELECT_COLOR][BG] & 255) | 0x80;
250 rtn = DefaultWndProc(wnd, PAINT, p1, p2);
251 *(cp+1) =
252 (pwnd->WindowColors[HILITE_COLOR][FG] & 255) | 0x80;
253 *(cp+2) =
254 (pwnd->WindowColors[HILITE_COLOR][BG] & 255) | 0x80;
255 return rtn;
256 }
257 return DefaultWndProc(wnd, PAINT, p1, p2);
258 }
259
260 /* ---- LEFT_BUTTON message for the helpbox text editbox ---- */
261 static int LeftButtonMsg(DFWINDOW wnd, PARAM p1, PARAM p2)
262 {
263 struct keywords *thisword;
264 int rtn, mx, my;
265
266 rtn = DefaultWndProc(wnd, LEFT_BUTTON, p1, p2);
267 mx = (int)p1 - GetClientLeft(wnd);
268 my = (int)p2 - GetClientTop(wnd);
269 my += wnd->wtop;
270 thisword = wnd->firstword;
271 while (thisword != NULL) {
272 if (my == thisword->lineno) {
273 if (mx >= thisword->off2 &&
274 mx < thisword->off3) {
275 wnd->thisword = thisword;
276 DfSendMessage(wnd, PAINT, 0, 0);
277 if (thisword->isDefinition) {
278 DFWINDOW pwnd = GetParent(wnd);
279 if (pwnd != NULL)
280 DisplayDefinition(GetParent(pwnd),
281 thisword->hname);
282 }
283 break;
284 }
285 }
286 thisword = thisword->nextword;
287 }
288 return rtn;
289 }
290
291 /* --- window processing module for HELPBOX's text EDITBOX -- */
292 int HelpTextProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
293 {
294 struct keywords *thisword;
295 switch (msg) {
296 case PAINT:
297 return PaintMsg(wnd, p1, p2);
298 case LEFT_BUTTON:
299 return LeftButtonMsg(wnd, p1, p2);
300 case DOUBLE_CLICK:
301 DfPostMessage(wnd, KEYBOARD, '\r', 0);
302 break;
303 case CLOSE_WINDOW:
304 thisword = wnd->firstword;
305 while (thisword != NULL) {
306 struct keywords *nextword = thisword->nextword;
307 if (thisword->hname != NULL)
308 free(thisword->hname);
309 free(thisword);
310 thisword = nextword;
311 }
312 break;
313 default:
314 break;
315 }
316 return DefaultWndProc(wnd, msg, p1, p2);
317 }
318
319 /* -------- read the help text into the editbox ------- */
320 static void ReadHelp(DFWINDOW wnd)
321 {
322 DFWINDOW cwnd = ControlWindow(wnd->extension, ID_HELPTEXT);
323 int linectr = 0;
324 if (cwnd == NULL)
325 return;
326 cwnd->wndproc = HelpTextProc;
327 /* ----- read the help text ------- */
328 while (TRUE) {
329 unsigned char *cp = hline, *cp1;
330 int colorct = 0;
331 if (GetHelpLine(hline) == NULL)
332 break;
333 if (*hline == '<')
334 break;
335 hline[strlen(hline)-1] = '\0';
336 /* --- add help text to the help window --- */
337 while (cp != NULL) {
338 if ((cp = strchr(cp, '[')) != NULL) {
339 /* ----- hit a new key word ----- */
340 struct keywords *thisword;
341 if (*(cp+1) != '.' && *(cp+1) != '*') {
342 cp++;
343 continue;
344 }
345 thisword = DFcalloc(1, sizeof(struct keywords));
346 if (cwnd->firstword == NULL)
347 cwnd->firstword = thisword;
348 if (cwnd->lastword != NULL) {
349 ((struct keywords *)
350 (cwnd->lastword))->nextword = thisword;
351 thisword->prevword = cwnd->lastword;
352 }
353 cwnd->lastword = thisword;
354 thisword->lineno = cwnd->wlines;
355 thisword->off1 = (int) ((int)cp - (int)hline);
356 thisword->off2 = thisword->off1 - colorct * 4;
357 thisword->isDefinition = *(cp+1) == '*';
358 colorct++;
359 *cp++ = CHANGECOLOR;
360 *cp++ =
361 (wnd->WindowColors [HILITE_COLOR] [FG] & 255) | 0x80;
362 *cp++ =
363 (wnd->WindowColors [HILITE_COLOR] [BG] & 255) | 0x80;
364 cp1 = cp;
365 if ((cp = strchr(cp, ']')) != NULL) {
366 if (thisword != NULL)
367 thisword->off3 =
368 thisword->off2 + (int) (cp - cp1);
369 *cp++ = RESETCOLOR;
370 }
371 if ((cp = strchr(cp, '<')) != NULL) {
372 char *cp1 = strchr(cp, '>');
373 if (cp1 != NULL) {
374 int len = (int) ((int)cp1 - (int)cp);
375 thisword->hname = DFcalloc(1, len);
376 strncpy(thisword->hname, cp+1, len-1);
377 memmove(cp, cp1+1, strlen(cp1));
378 }
379 }
380 }
381 }
382 PutItemText(wnd, ID_HELPTEXT, hline);
383 /* -- display help text as soon as window is full -- */
384 if (++linectr == ClientHeight(cwnd))
385 DfSendMessage(cwnd, PAINT, 0, 0);
386 if (linectr > ClientHeight(cwnd) &&
387 !TestAttribute(cwnd, VSCROLLBAR)) {
388 AddAttribute(cwnd, VSCROLLBAR);
389 DfSendMessage(cwnd, BORDER, 0, 0);
390 }
391 }
392 }
393
394 /* ---- compute the displayed length of a help text line --- */
395 static int HelpLength(char *s)
396 {
397 int len = strlen(s);
398 char *cp = strchr(s, '[');
399 while (cp != NULL) {
400 len -= 4;
401 cp = strchr(cp+1, '[');
402 }
403 cp = strchr(s, '<');
404 while (cp != NULL) {
405 char *cp1 = strchr(cp, '>');
406 if (cp1 != NULL)
407 len -= (int) (cp1-cp)+1;
408 cp = strchr(cp1, '<');
409 }
410 return len;
411 }
412
413 /* ----------- load the help text file ------------ */
414 void LoadHelpFile()
415 {
416 char *cp;
417
418 if (Helping)
419 return;
420 UnLoadHelpFile();
421 if ((helpfp = OpenHelpFile()) == NULL)
422 return;
423 *hline = '\0';
424 while (*hline != '<') {
425 if (GetHelpLine(hline) == NULL) {
426 fclose(helpfp);
427 return;
428 }
429 }
430 while (*hline == '<') {
431 if (strncmp(hline, "<end>", 5) == 0)
432 break;
433
434 /* -------- parse the help window's text name ----- */
435 if ((cp = strchr(hline, '>')) != NULL) {
436 ThisHelp = DFcalloc(1, sizeof(struct helps));
437 if (FirstHelp == NULL)
438 FirstHelp = ThisHelp;
439 *cp = '\0';
440 ThisHelp->hname=DFmalloc(strlen(hline+1)+1);
441 strcpy(ThisHelp->hname, hline+1);
442
443 HelpFilePosition(&ThisHelp->hptr, &ThisHelp->bit);
444
445 if (GetHelpLine(hline) == NULL)
446 break;
447
448 /* ------- build the help linked list entry --- */
449 while (*hline == '[') {
450 HelpFilePosition(&ThisHelp->hptr,
451 &ThisHelp->bit);
452 /* ---- parse the <<prev button pointer ---- */
453 if (strncmp(hline, "[<<]", 4) == 0) {
454 char *cp = strchr(hline+4, '<');
455 if (cp != NULL) {
456 char *cp1 = strchr(cp, '>');
457 if (cp1 != NULL) {
458 int len = (int) (cp1-cp);
459 ThisHelp->PrevName=DFcalloc(1,len);
460 strncpy(ThisHelp->PrevName,
461 cp+1,len-1);
462 }
463 }
464 if (GetHelpLine(hline) == NULL)
465 break;
466 continue;
467 }
468 /* ---- parse the next>> button pointer ---- */
469 else if (strncmp(hline, "[>>]", 4) == 0) {
470 char *cp = strchr(hline+4, '<');
471 if (cp != NULL) {
472 char *cp1 = strchr(cp, '>');
473 if (cp1 != NULL) {
474 int len = (int) (cp1-cp);
475 ThisHelp->NextName=DFcalloc(1,len);
476 strncpy(ThisHelp->NextName,
477 cp+1,len-1);
478 }
479 }
480 if (GetHelpLine(hline) == NULL)
481 break;
482 continue;
483 }
484 else
485 break;
486 }
487 ThisHelp->hheight = 0;
488 ThisHelp->hwidth = 0;
489 ThisHelp->NextHelp = NULL;
490
491 /* ------ append entry to the linked list ------ */
492 if (LastHelp != NULL)
493 LastHelp->NextHelp = ThisHelp;
494 LastHelp = ThisHelp;
495 }
496 /* -------- move to the next <helpname> token ------ */
497 if (GetHelpLine(hline) == NULL)
498 strcpy(hline, "<end>");
499 while (*hline != '<') {
500 ThisHelp->hwidth =
501 max(ThisHelp->hwidth, HelpLength(hline));
502 ThisHelp->hheight++;
503 if (GetHelpLine(hline) == NULL)
504 strcpy(hline, "<end>");
505 }
506 }
507 fclose(helpfp);
508 }
509
510 /* ------ free the memory used by the help file table ------ */
511 void UnLoadHelpFile(void)
512 {
513 while (FirstHelp != NULL) {
514 ThisHelp = FirstHelp;
515 if (ThisHelp->hname != NULL)
516 free(ThisHelp->hname);
517 if (ThisHelp->PrevName != NULL)
518 free(ThisHelp->PrevName);
519 if (ThisHelp->NextName != NULL)
520 free(ThisHelp->NextName);
521 FirstHelp = ThisHelp->NextHelp;
522 free(ThisHelp);
523 }
524 ThisHelp = LastHelp = NULL;
525 free(HelpTree);
526 HelpTree = NULL;
527 }
528
529 /* ---------- display a specified help text ----------- */
530 BOOL DisplayHelp(DFWINDOW wnd, char *Help)
531 {
532 BOOL rtn = FALSE;
533 if (Helping)
534 return TRUE;
535 wnd->isHelping++;
536 FindHelp(Help);
537 if (ThisHelp != NULL) {
538 if (LastStack == NULL ||
539 stricmp(Help, LastStack->hname)) {
540 /* ---- add the window to the history stack ---- */
541 ThisStack = DFcalloc(1,sizeof(struct HelpStack));
542 ThisStack->hname = DFmalloc(strlen(Help)+1);
543 if (ThisStack->hname != NULL)
544 strcpy(ThisStack->hname, Help);
545 ThisStack->PrevStack = LastStack;
546 LastStack = ThisStack;
547 }
548 if ((helpfp = OpenHelpFile()) != NULL) {
549 DBOX *db;
550 int offset, i;
551
552 db = DFcalloc(1,sizeof HelpBox);
553 memcpy(db, &HelpBox, sizeof HelpBox);
554 /* -- seek to the first line of the help text -- */
555 SeekHelpLine(ThisHelp->hptr, ThisHelp->bit);
556 /* ----- read the title ----- */
557 GetHelpLine(hline);
558 hline[strlen(hline)-1] = '\0';
559 db->dwnd.title = DFmalloc(strlen(hline)+1);
560 strcpy(db->dwnd.title, hline);
561 /* ----- set the height and width ----- */
562 db->dwnd.h = min(ThisHelp->hheight, MAXHEIGHT)+7;
563 db->dwnd.w = max(45, ThisHelp->hwidth+6);
564 /* ------ position the help window ----- */
565 BestFit(wnd, &db->dwnd);
566 /* ------- position the command buttons ------ */
567 db->ctl[0].dwnd.w = max(40, ThisHelp->hwidth+2);
568 db->ctl[0].dwnd.h =
569 min(ThisHelp->hheight, MAXHEIGHT)+2;
570 offset = (db->dwnd.w-40) / 2;
571 for (i = 1; i < 5; i++) {
572 db->ctl[i].dwnd.y =
573 min(ThisHelp->hheight, MAXHEIGHT)+3;
574 db->ctl[i].dwnd.x += offset;
575 }
576 /* ---- disable ineffective buttons ---- */
577 if (ThisStack != NULL)
578 if (ThisStack->PrevStack == NULL)
579 DisableButton(db, ID_BACK);
580 if (ThisHelp->NextName == NULL)
581 DisableButton(db, ID_NEXT);
582 if (ThisHelp->PrevName == NULL)
583 DisableButton(db, ID_PREV);
584 /* ------- display the help window ----- */
585 DfDialogBox(NULL, db, TRUE, HelpBoxProc);
586 free(db);
587 fclose(helpfp);
588 rtn = TRUE;
589 }
590 }
591 --wnd->isHelping;
592 return rtn;
593 }
594
595 /* ------- display a definition window --------- */
596 static void DisplayDefinition(DFWINDOW wnd, char *def)
597 {
598 DFWINDOW dwnd;
599 DFWINDOW hwnd = wnd;
600 int y;
601
602 if (GetClass(wnd) == POPDOWNMENU)
603 hwnd = GetParent(wnd);
604 y = GetClass(hwnd) == MENUBAR ? 2 : 1;
605 FindHelp(def);
606 if (ThisHelp != NULL) {
607 if ((helpfp = OpenHelpFile()) != NULL) {
608 dwnd = DfCreateWindow(
609 TEXTBOX,
610 NULL,
611 GetClientLeft(hwnd),
612 GetClientTop(hwnd)+y,
613 min(ThisHelp->hheight, MAXHEIGHT)+3,
614 ThisHelp->hwidth+2,
615 NULL,
616 wnd,
617 NULL,
618 HASBORDER | NOCLIP | SAVESELF);
619 if (dwnd != NULL) {
620 /* ----- read the help text ------- */
621 SeekHelpLine(ThisHelp->hptr, ThisHelp->bit);
622 while (TRUE) {
623 if (GetHelpLine(hline) == NULL)
624 break;
625 if (*hline == '<')
626 break;
627 hline[strlen(hline)-1] = '\0';
628 DfSendMessage(dwnd,ADDTEXT,(PARAM)hline,0);
629 }
630 DfSendMessage(dwnd, SHOW_WINDOW, 0, 0);
631 DfSendMessage(NULL, WAITKEYBOARD, 0, 0);
632 DfSendMessage(NULL, WAITMOUSE, 0, 0);
633 DfSendMessage(dwnd, CLOSE_WINDOW, 0, 0);
634 }
635 fclose(helpfp);
636 }
637 }
638 }
639
640 /* ------ compare help names with wild cards ----- */
641 static BOOL wildcmp(char *s1, char *s2)
642 {
643 while (*s1 || *s2) {
644 if (tolower(*s1) != tolower(*s2))
645 if (*s1 != '?' && *s2 != '?')
646 return TRUE;
647 s1++, s2++;
648 }
649 return FALSE;
650 }
651
652 /* --- ThisHelp = the help window matching specified name --- */
653 static void FindHelp(char *Help)
654 {
655 ThisHelp = FirstHelp;
656 while (ThisHelp != NULL) {
657 if (wildcmp(Help, ThisHelp->hname) == FALSE)
658 break;
659 ThisHelp = ThisHelp->NextHelp;
660 }
661 }
662
663 /* --- ThisHelp = the help window matching specified wnd --- */
664 static void FindHelpWindow(DFWINDOW wnd)
665 {
666 ThisHelp = FirstHelp;
667 while (ThisHelp != NULL) {
668 if (wnd == ThisHelp->hwnd)
669 break;
670 ThisHelp = ThisHelp->NextHelp;
671 }
672 }
673
674 static int OverLap(int a, int b)
675 {
676 int ov = a - b;
677 if (ov < 0)
678 ov = 0;
679 return ov;
680 }
681
682 /* ----- compute the best location for a help dialogbox ----- */
683 static void BestFit(DFWINDOW wnd, DIALOGWINDOW *dwnd)
684 {
685 int above, below, right, left;
686 if (GetClass(wnd) == MENUBAR ||
687 GetClass(wnd) == APPLICATION) {
688 dwnd->x = dwnd->y = -1;
689 return;
690 }
691 /* --- compute above overlap ---- */
692 above = OverLap(dwnd->h, GetTop(wnd));
693 /* --- compute below overlap ---- */
694 below = OverLap(GetBottom(wnd), DfGetScreenHeight()-dwnd->h);
695 /* --- compute right overlap ---- */
696 right = OverLap(GetRight(wnd), DfGetScreenWidth()-dwnd->w);
697 /* --- compute left overlap ---- */
698 left = OverLap(dwnd->w, GetLeft(wnd));
699
700 if (above < below)
701 dwnd->y = max(0, GetTop(wnd)-dwnd->h-2);
702 else
703 dwnd->y = min(DfGetScreenHeight()-dwnd->h, GetBottom(wnd)+2);
704 if (right < left)
705 dwnd->x = min(GetRight(wnd)+2, DfGetScreenWidth()-dwnd->w);
706 else
707 dwnd->x = max(0, GetLeft(wnd)-dwnd->w-2);
708
709 if (dwnd->x == GetRight(wnd)+2 ||
710 dwnd->x == GetLeft(wnd)-dwnd->w-2)
711 dwnd->y = -1;
712 if (dwnd->y ==GetTop(wnd)-dwnd->h-2 ||
713 dwnd->y == GetBottom(wnd)+2)
714 dwnd->x = -1;
715 }
716
717 /* EOF */