revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / reqtools / filereqsetup.c
blobccd67dc06b14a93bf84f77e3c80db088bc4f0ef7
1 /**************************************************************
2 * *
3 * File/Font/Screenmode requester *
4 * *
5 * (c) Nico François 1991-1994 *
6 **************************************************************/
8 #include "filereq.h"
10 /****************************************************************************************/
12 /***************************
13 * *
14 * REQUESTER WINDOW SETUP *
15 * *
16 ***************************/
18 /****************************************************************************************/
20 static void REGARGS CheckGadgetsSize (ULONG *gadlen, ULONG *width, ULONG availwidth, ULONG num)
22 ULONG overlap;
23 int i;
25 if (availwidth >= *width) return;
27 overlap = ((((*width - availwidth) << 16) / num) + 0xffff) >> 16;
28 for (i = 0; i < num; i++)
30 gadlen[i] -= overlap;
31 *width -= overlap;
35 /****************************************************************************************/
37 static char *oscanlabs_cat[] =
38 { MSG_REGULAR_SIZE, MSG_TEXT_SIZE, MSG_GFX_SIZE, MSG_MAX_SIZE, NULL };
40 /****************************************************************************************/
42 void REGARGS RenderLED (GlobData *glob)
44 if (glob->led_x)
46 SetDrMd (glob->reqrp, JAM2);
47 SetAPen (glob->reqrp, glob->pens[glob->ledon ? FILLPEN : BACKGROUNDPEN]);
48 RectFill (glob->reqrp, glob->led_x + 2, glob->led_y + 1,
49 glob->led_x + glob->led_w - 3, glob->led_y + glob->led_h - 2);
53 /****************************************************************************************/
55 void REGARGS RenderReqWindow (GlobData *glob, int refresh, int dowait)
57 if (refresh)
58 GT_BeginRefresh (glob->reqwin);
60 RenderLED (glob);
61 if (glob->numselectedgad)
62 UpdateNumSelGad (glob);
64 if (glob->reqtype == RT_FONTREQ)
65 ShowFontSample (glob, refresh, dowait);
67 if (refresh)
69 PrintFiles (glob);
70 GT_EndRefresh (glob->reqwin, TRUE);
74 /****************************************************************************************/
76 static int scrollpens[] =
77 { TEXTPEN,FILLPEN,FILLTEXTPEN,BACKGROUNDPEN,HIGHLIGHTTEXTPEN,-1 };
79 /****************************************************************************************/
81 int REGARGS SetupReqWindow (GlobData *glob, int resized)
83 struct NewGadget ng;
84 struct Gadget *gad;
85 struct Image *img;
86 struct ReqDefaults *reqdefs;
87 struct ReqToolsPrefs *reqtoolsprefs;
88 int top, val, val2, buttonheight, spacing, winheight;
89 int scrwidth, scrheight, createpatgad, createstyle, winwidth, start_top;
90 int i, width1, width2, num1, num2;
91 int firsttime = TRUE;
92 int isfilereq, isfontreq, isvolreq, isscreenmodereq, checkboxcount;
93 int stdgadheight, defaultheight, dotinfowidth;
94 int gadlen[8] , gadpos[8], reqdefnum = 0, maxpen;
95 int overscanstrlen = 0, widthstrlen = 0, heightstrlen = 0, widthheightlen = 0, dimgadwidth = 0;
96 int reqpos, check, led_off = 0, do_led;
97 int checkw, checkh, checkskip, checktopoff;
98 int leftoff, rightoff, totaloff;
99 char **gadtxt = glob->gadtxt, *str, *dotinfostr;
100 char *overscanstr = NULL, *widthstr = NULL, *heightstr = NULL, *defaultstr = NULL;
101 ULONG mask;
105 defaultheight = (glob->reqheight == 0);
106 spacing = rtGetVScreenSize (glob->scr, (ULONG *)&scrwidth, (ULONG *)&scrheight);
107 createpatgad = (glob->flags & FREQF_PATGAD) && !(glob->flags & FREQF_NOFILES);
108 createstyle = (glob->flags & FREQF_STYLE);
109 isvolreq = (glob->volumerequest);
110 isfilereq = (glob->reqtype == RT_FILEREQ) && !isvolreq;
111 isfontreq = (glob->reqtype == RT_FONTREQ);
112 isscreenmodereq = (glob->reqtype == RT_SCREENMODEREQ);
113 stdgadheight = glob->fontheight + 6;
115 glob->entryheight = glob->fontheight + 1;
118 switch (glob->reqtype)
120 case RT_FILEREQ:
121 if (isvolreq) reqdefnum = RTPREF_VOLUMEREQ;
122 else reqdefnum = RTPREF_FILEREQ;
123 break;
125 case RT_FONTREQ:
126 reqdefnum = RTPREF_FONTREQ;
127 break;
129 case RT_SCREENMODEREQ:
130 reqdefnum = RTPREF_SCREENMODEREQ;
131 break;
135 leftoff = glob->scr->WBorLeft + 5;
136 rightoff = glob->scr->WBorRight + 5;
137 totaloff = (leftoff + rightoff);
140 //rebuildwindow:
141 reqdefs = &rtLockPrefs()->ReqDefaults[reqdefnum];
143 if (!glob->reqheight)
145 glob->reqheight = ((int)reqdefs->Size * scrheight) / 100;
147 else if (!resized)
149 if (glob->reqheight > scrheight) glob->reqheight = scrheight;
152 rtUnlockPrefs();
155 start_top = (glob->scr->WBorTop + glob->scr->Font->ta_YSize + 1) + spacing;
157 ng.ng_VisualInfo = glob->visinfo;
158 ng.ng_TextAttr = &glob->font;
159 glob->itxt.ITextFont = &glob->font;
162 checkw = CheckBoxWidth (&ng);
163 checkh = checkskip = CheckBoxHeight (&ng);
164 if (glob->fontheight > checkskip) checkskip = glob->fontheight;
167 if (isfilereq)
169 val = (stdgadheight + spacing) * 4 + 4;
170 if (createpatgad) val += stdgadheight + spacing / 2;
171 if (glob->flags & FREQF_NOFILES) val -= stdgadheight + spacing;
172 if (!(glob->flags & FREQF_MULTISELECT)) val -= stdgadheight + spacing;
174 else if (isfontreq)
176 val = stdgadheight * 2 + spacing * 3 + spacing / 2 + 8 + glob->sampleheight;
177 if (createstyle) val += checkskip + 4 + spacing;
179 else if (isvolreq)
181 val = (stdgadheight + spacing) * 2 + spacing / 2 + 4;
183 else
185 val = stdgadheight + glob->fontheight + spacing * 2 + 8;
186 if (glob->flags & SCREQF_SIZEGADS)
187 val += spacing + stdgadheight * 2 + spacing / 2;
188 if (glob->flags & SCREQF_DEPTHGAD)
189 val += glob->fontheight + 3 + spacing;
190 if (glob->flags & SCREQF_OVERSCANGAD)
191 val += stdgadheight + spacing;
192 if (glob->flags & SCREQF_AUTOSCROLLGAD)
193 val += checkskip + spacing;
195 glob->numentries = (glob->reqheight - val - start_top
196 - BottomBorderHeight (glob->scr)) / glob->entryheight;
199 retryopenwindow:
201 top = start_top;
203 gad = (struct Gadget *)CreateContext (&glob->buttoninfo.glist);
204 img = &glob->labelimages;
207 reqtoolsprefs = rtLockPrefs();
209 do_led = !(reqtoolsprefs->Flags & RTPRF_NOLED);
210 reqdefs = &(reqtoolsprefs->ReqDefaults[reqdefnum]);
212 val = (!firsttime || !defaultheight) ? 3 : reqdefs->MinEntries;
213 if (glob->numentries < val) glob->numentries = val;
214 firsttime = FALSE;
215 val = !defaultheight ? 50 : reqdefs->MaxEntries;
216 if (glob->numentries > val) glob->numentries = val;
218 rtUnlockPrefs();
221 /* calculate width of gadgets and window */
222 gadtxt[7] = GetStr (glob->catalog, MSG_CANCEL);
223 glob->led_x = 0;
224 if (isfilereq || isfontreq)
226 for (i = 0; i < 4; i++) gadlen[i] = 0;
227 if (isfilereq)
229 if (do_led)
231 glob->led_h = glob->fontheight - 4;
232 if (glob->led_h < 7) glob->led_h = 7;
233 glob->led_w = 15 + (glob->led_h - 7) * 2;
234 glob->led_x = leftoff;
235 led_off = glob->led_w + 6;
237 gadtxt[0] = GetStr (glob->catalog, MSG_SELECTED);
238 gadlen[0] = StrWidth_noloc (&glob->itxt, "0000");
239 gadtxt[1] = GetStr (glob->catalog, MSG_ALL);
240 gadtxt[2] = GetStr (glob->catalog, MSG_MATCH);
241 gadtxt[3] = GetStr (glob->catalog, MSG_CLEAR);
242 num1 = 4;
243 gadtxt[5] = GetStr (glob->catalog, MSG_VOLUMES);
244 gadtxt[6] = GetStr (glob->catalog, MSG_PARENT);
245 num2 = 4;
247 else
249 gadtxt[0] = GetStr (glob->catalog, MSG_BOLD);
250 gadtxt[1] = GetStr (glob->catalog, MSG_ITALIC);
251 gadtxt[2] = GetStr (glob->catalog, MSG_UNDERLINE);
252 for (i = 0; i < 3; i++) gadlen[i] = checkw + 8 - 16;
253 num1 = 3;
254 num2 = 2;
257 /* Calculate width of top row of gadgets */
258 width1 = 0;
259 for (i = 0; i < num1; i++)
261 gadlen[i] += StrWidth_noloc (&glob->itxt, gadtxt[i]) + 16;
262 width1 += gadlen[i];
265 else
267 /* isvolreq or screenmode request */
268 num1 = 4; num2 = 2;
269 width1 = 0;
271 if (num2 == 2) gadtxt[5] = gadtxt[7];
274 /* Calculate width of button row of gadgets */
275 width2 = 0;
276 for (i = 0; i < num2; i++)
278 val = StrWidth_noloc (&glob->itxt, gadtxt[i+4]) + 16;
279 if (val > width2) width2 = val;
281 for (i = 0; i < num2; i++) gadlen[i+4] = width2;
282 width2 *= num2;
285 if (isfilereq && !(glob->flags & FREQF_MULTISELECT)) width1 = 0;
288 if (isscreenmodereq)
290 int len;
293 overscanstr = GetStr (glob->catalog, MSG_OVERSCAN);
294 overscanstrlen = StrWidth_noloc (&glob->itxt, overscanstr);
295 widthstr = GetStr (glob->catalog, MSG_WIDTH);
296 widthstrlen = widthheightlen = StrWidth_noloc (&glob->itxt, widthstr);
297 heightstr = GetStr (glob->catalog, MSG_HEIGHT);
298 heightstrlen = StrWidth_noloc (&glob->itxt, heightstr);
299 if (heightstrlen > widthheightlen) widthheightlen = heightstrlen;
300 defaultstr = GetStr (glob->catalog, MSG_DEFAULT);
301 winwidth = 276;
302 val = len = 0;
304 if (glob->flags & SCREQF_OVERSCANGAD)
306 if (overscanstrlen > widthheightlen) widthheightlen = overscanstrlen;
307 for (i = 0; oscanlabs_cat[i]; i++)
309 glob->oscanlabs[i] = GetStr (glob->catalog, oscanlabs_cat[i]);
310 val = StrWidth_noloc (&glob->itxt, glob->oscanlabs[i]);
311 if (val > len) len = val;
313 val = len + overscanstrlen + 36 + 8 + (rightoff + leftoff) + 2;
315 if (glob->flags & SCREQF_SIZEGADS)
317 dimgadwidth = StrWidth_noloc (&glob->itxt, "000000") + 12;
318 val2 = widthheightlen + StrWidth_noloc (&glob->itxt, defaultstr) +
319 dimgadwidth + 8 + 8 + checkw + 8 + 4 + totaloff;
320 if (val2 > val) val = val2;
323 else
325 winwidth = width1 + (num1-1) * 8 + totaloff;
326 if (isfontreq) winwidth += 12;
327 if (winwidth < 300) winwidth = 300;
328 val = width2 + (num2-1) * 8 + totaloff;
331 if (val > winwidth) winwidth = val;
332 if (winwidth > scrwidth) winwidth = scrwidth;
333 if (isfontreq || (isfilereq && (glob->flags & FREQF_MULTISELECT)))
335 CheckGadgetsSize ((ULONG *)gadlen, (ULONG *)&width1, winwidth - totaloff, num1);
336 rtSpread ((ULONG *)gadpos, (ULONG *)gadlen, width1, leftoff, winwidth - rightoff, num1);
339 CheckGadgetsSize ((ULONG *)gadlen + 4, (ULONG *)&width2, winwidth - totaloff, num2);
341 rtSpread ((ULONG *)gadpos + 4, (ULONG *)gadlen + 4, width2, leftoff, winwidth - rightoff, num2);
343 if (num2 == 2)
345 gadpos[7] = gadpos[5];
346 gadlen[7] = gadlen[5];
350 if (isfilereq && (glob->flags & FREQF_MULTISELECT) && (width2 > width1))
352 for (i = 1; i < 4; i++)
354 val = gadpos[i-1] + gadlen[i-1] + 8;
355 gadlen[i] += (gadpos[i] - val);
356 gadpos[i] = val;
361 glob->boxleft = leftoff + 2; glob->boxtop = top + 2;
362 glob->boxheight = glob->numentries * glob->entryheight;
363 glob->boxright = winwidth - 21 - rightoff;
365 /* create files gadget and scroller gadget */
366 ng.ng_Flags = 0;
367 InitNewGadget (&ng, leftoff + 4, top + 2,
368 winwidth - 26 - totaloff, glob->boxheight, NULL, FILES);
370 gad = myCreateGadget (GENERIC_KIND, gad, &ng, TAG_END);
371 if (gad)
373 gad->GadgetType |= GTYP_BOOLGADGET;
374 gad->Flags |= GFLG_GADGHNONE;
375 gad->Activation |= GACT_IMMEDIATE|GACT_FOLLOWMOUSE|GACT_RELVERIFY;
378 ng.ng_LeftEdge -= 4;
379 ng.ng_Width += 8;
380 ng.ng_TopEdge -= 2;
381 ng.ng_Height += 4;
382 ng.ng_GadgetID = 0;
384 gad = my_CreateButtonGadget (gad, 0, &ng);
386 if (gad) gad->Flags |= GFLG_GADGHNONE;
388 InitNewGadget (&ng, winwidth - 18 - rightoff, top, 18, glob->boxheight + 4, NULL, FPROP);
389 gad = glob->scrollergad = myCreateGadget (SCROLLER_KIND, gad, &ng, GTSC_Visible, glob->numentries,
390 GTSC_Arrows, glob->fontheight + 1,
391 PGA_Freedom, LORIENT_VERT,
392 GTSC_Top, glob->buff->pos,
393 GTSC_Total, glob->buff->currentnum,
394 GA_RelVerify, TRUE,
395 GA_Immediate, TRUE,
396 TAG_END);
397 top += glob->boxheight + 4 + spacing / 2;
400 if (isfilereq || isvolreq)
404 * File Requester gadgets
407 glob->strgaduserdata.flags = USERFLAG_UP_DOWN_ARROW;
408 glob->fnamegaduserdata.flags = USERFLAG_UP_DOWN_ARROW|USERFLAG_MATCH_FILE;
409 glob->fnamegaduserdata.proc = ThisProcess();
411 /* create string gadgets */
412 if (createpatgad)
414 str = GetStr (glob->catalog, MSG_PATTERN);
415 glob->patkey = KeyFromStr (str, '_');
416 val = StrWidth_noloc (&glob->itxt, str) + 8;
417 InitNewGadget (&ng, leftoff + 2 + val, top, winwidth - 2 - val - totaloff,
418 stdgadheight, NULL, PATSTR);
419 glob->patgad = gad = my_CreateStringGadget (gad, &ng, 60, glob->freq->patstr);
420 if (gad)
422 glob->patgadstr = ((struct StringInfo *)gad->SpecialInfo)->Buffer;
423 gad->UserData = &glob->strgaduserdata;
425 img = my_CreateGadgetLabelImage (img, &ng, str, leftoff + 2, top + 3, TEXTPEN);
426 top += ng.ng_Height + spacing / 2;
428 else glob->patgad = NULL;
430 dotinfostr = GetStr (glob->catalog, MSG_DOT_INFO);
431 dotinfowidth = StrWidth_noloc (&glob->itxt, dotinfostr) + 8;
432 if (isfilereq)
434 str = GetStr (glob->catalog, MSG_GET);
435 val = StrWidth_noloc (&glob->itxt, str) + 8;
437 if (val > dotinfowidth) dotinfowidth = val;
439 val = dotinfowidth;
440 InitNewGadget (&ng, winwidth - rightoff - val, top, val,
441 stdgadheight, str, GETDIR);
442 gad = my_CreateButtonGadget (gad, '_', &ng);
444 else val = 0;
446 InitNewGadget (&ng, leftoff + led_off, top, winwidth - totaloff - val - led_off,
447 stdgadheight, NULL, DRAWERSTR);
448 gad = glob->drawergad =
449 my_CreateStringGadget (gad, &ng, 255, glob->freq->dirname);
451 if (gad)
453 glob->led_y = top + (stdgadheight - glob->led_h - 1) / 2;
454 glob->drawerstr = ((struct StringInfo *)gad->SpecialInfo)->Buffer;
455 if (!(glob->flags & FREQF_NOFILES))
456 gad->UserData = &glob->strgaduserdata;
459 top += ng.ng_Height + spacing / 2;
460 if (!(glob->flags & FREQF_NOFILES))
462 ng.ng_TopEdge = top;
463 ng.ng_LeftEdge -= led_off;
464 ng.ng_Width += led_off;
465 ng.ng_GadgetID = FILESTR;
466 gad = glob->filegad = my_CreateStringGadget (gad, &ng, 107, NULL);
467 if ((glob->mainstrgad = gad))
468 gad->UserData = &glob->fnamegaduserdata;
470 ng.ng_LeftEdge = winwidth - rightoff - val;
471 ng.ng_Width = dotinfowidth;
472 ng.ng_GadgetText = dotinfostr;
473 ng.ng_GadgetID = INFO;
474 gad = my_CreateButtonGadget (gad, '_', &ng);
475 if (gad)
477 gad->Activation |= GACT_TOGGLESELECT;
478 if (!glob->freq->hideinfo) gad->Flags |= GFLG_SELECTED;
481 top += ng.ng_Height + spacing;
483 else
485 glob->filegad = NULL;
486 glob->mainstrgad = glob->drawergad;
487 top += spacing / 2;
490 if (glob->led_x)
492 InitNewGadget (&ng, glob->led_x, glob->led_y, glob->led_w, glob->led_h, NULL, 0);
493 gad = myCreateGadget (TEXT_KIND, gad, &ng, GTTX_Border, TRUE, TAG_END);
496 } /* if (isfilereq || isvolreq) */
497 else if (isfontreq)
501 * Font Requester gadgets
504 InitNewGadget (&ng, leftoff, top, winwidth - 65 - totaloff, stdgadheight, NULL, FILESTR);
505 gad = glob->filegad = my_CreateStringGadget (gad, &ng, 107, NULL);
506 glob->mainstrgad = glob->filegad;
507 ng.ng_LeftEdge = winwidth - 57 - rightoff; ng.ng_Width = 57; ng.ng_GadgetID = FONTSIZE;
508 gad = glob->drawergad = my_CreateIntegerGadget (gad, &ng, 4,
509 glob->fontreq->Attr.ta_YSize, GACT_STRINGLEFT);
510 top += ng.ng_Height + spacing;
512 glob->fontdisplayleft = leftoff + 4; glob->fontdisplayright = winwidth - rightoff - 5;
513 glob->fontdisplaytop = top + 2;
514 InitNewGadget (&ng, leftoff, top, winwidth - totaloff, glob->sampleheight + 4, NULL, 0);
515 gad = myCreateGadget (TEXT_KIND, gad, &ng, GTTX_Border, TRUE, TAG_END);
516 top += glob->sampleheight + 4 + spacing;
518 glob->fontstyle = glob->fontreq->Attr.ta_Style;
520 else
525 * ScreenMode Requester gadgets
528 top -= spacing / 2;
529 InitNewGadget (&ng, leftoff, top, winwidth - totaloff, glob->fontheight + 4, NULL, 0);
530 /* Remove this one please. ;) */
531 gad = glob->modetxtgad = myCreateGadget (TEXT_KIND, gad, &ng,
532 GTTX_Text, (IPTR) glob->nameinfo.Name,
533 GTTX_Border, TRUE, TAG_END);
534 top += ng.ng_Height + spacing;
537 if (glob->flags & SCREQF_OVERSCANGAD)
539 glob->overscankey = KeyFromStr (overscanstr, '_');
540 val = overscanstrlen + 8;
541 InitNewGadget (&ng, leftoff + 2 + val, top, winwidth - rightoff - leftoff - 2 - val,
542 stdgadheight, NULL, OVERSCN);
544 gad = glob->overscangad = myCreateGadget (CYCLE_KIND, gad, &ng,
545 GTCY_Labels, (IPTR) glob->oscanlabs,
546 GTCY_Active, glob->overscantype,
547 TAG_END);
549 img = my_CreateGadgetLabelImage (img, &ng, overscanstr,
550 leftoff + 2, top + 3, TEXTPEN);
551 top += stdgadheight + spacing;
555 if (glob->flags & SCREQF_SIZEGADS)
558 /* Screen width and height gadgets */
559 glob->widthkey = KeyFromStr (widthstr, '_');
561 val = widthheightlen + 8 + leftoff + 2;
562 InitNewGadget (&ng, val, top, dimgadwidth, stdgadheight, NULL, SCRWIDTH);
564 gad = glob->widthgad = my_CreateIntegerGadget (gad, &ng, 5,
565 glob->width, GACT_STRINGLEFT);
567 img = my_CreateGadgetLabelImage (img, &ng, widthstr,
569 val - 8 - widthstrlen, top + 3, TEXTPEN);
572 ng.ng_Flags = PLACETEXT_RIGHT;
574 checktopoff = 3 - (checkh - glob->fontheight + 1) / 2;
575 ng.ng_TopEdge = top + (glob->os30 ? checktopoff : 1);
576 ng.ng_LeftEdge += dimgadwidth + 8;
577 ng.ng_Width = checkw;
578 ng.ng_Height = checkh;
579 ng.ng_GadgetText = defaultstr;
580 ng.ng_GadgetID = DEFWIDTH;
582 gad = glob->defwgad = myCreateGadget (CHECKBOX_KIND, gad, &ng, GTCB_Scaled, TRUE,
583 GTCB_Checked, glob->usedefwidth,
584 TAG_END);
586 top += stdgadheight + spacing / 2;
588 ng.ng_TopEdge = top + (glob->os30 ? checktopoff : 1);
589 ng.ng_GadgetID = DEFHEIGHT;
591 gad = glob->defhgad = myCreateGadget (CHECKBOX_KIND, gad, &ng, GTCB_Scaled, TRUE,
592 GTCB_Checked, glob->usedefheight,
593 TAG_END);
596 ng.ng_Flags = 0;
598 ng.ng_TopEdge = top;
599 ng.ng_LeftEdge = val;
600 ng.ng_Width = dimgadwidth;
601 ng.ng_Height = stdgadheight;
602 ng.ng_GadgetText = NULL;
603 ng.ng_GadgetID = SCRHEIGHT;
604 str = heightstr;
605 glob->heightkey = KeyFromStr (str, '_');
607 gad = glob->heightgad = my_CreateIntegerGadget (gad, &ng, 5,
609 glob->height, GACT_STRINGLEFT);
611 img = my_CreateGadgetLabelImage (img, &ng, str,
612 val - 8 - heightstrlen, top + 3, TEXTPEN);
615 top += ng.ng_Height + spacing;
618 if (glob->flags & SCREQF_DEPTHGAD)
622 /* Colors gadget */
623 str = GetStr (glob->catalog, MSG_COLORS);
624 glob->depthkey = KeyFromStr (str, '_');
625 val = StrWidth_noloc (&glob->itxt, str) + 8;
626 val2 = StrWidth_noloc (&glob->itxt, GetStr (glob->catalog, MSG_MAX));
627 InitNewGadget (&ng, leftoff + 2 + val, top, StrWidth_noloc (&glob->itxt, "0000 "),
628 glob->fontheight + 3, NULL, 0);
629 BuildColStr (glob->currcolstr, glob->depth, glob->modeid);
630 gad = glob->currcolgad = myCreateGadget (TEXT_KIND, gad, &ng,
631 GTTX_Text, (IPTR) glob->currcolstr, GTTX_Clipped, TRUE,
632 (GadToolsBase->lib_Version >= 40) ? GTTX_Justification : TAG_IGNORE, GTJ_RIGHT, TAG_END);
633 ng.ng_LeftEdge += ng.ng_Width + 8;
634 val = StrWidth_noloc (&glob->itxt, "0000 ");
635 ng.ng_Width = winwidth - 22 - rightoff - ng.ng_LeftEdge - val - val2;
636 ng.ng_GadgetID = DEPTH;
638 gad = glob->depthgad = myCreateGadget (SLIDER_KIND, gad, &ng,
639 GA_RelVerify, TRUE, GA_Immediate , TRUE,
640 GTSL_Min, glob->currmindepth, GTSL_Max, glob->currmaxdepth,
641 GTSL_Level, glob->depth,
642 GA_Disabled, (glob->currmindepth == glob->currmaxdepth), TAG_END);
644 img = my_CreateGadgetLabelImage (img, &ng, str,
645 leftoff + 2, top + 2, TEXTPEN);
647 ng.ng_LeftEdge += ng.ng_Width + val2 + 20;
648 ng.ng_GadgetText = GetStr (glob->catalog, MSG_MAX);
649 ng.ng_Width = val;
650 BuildColStr (glob->maxcolstr, glob->currmaxdepth, 0);
651 gad = glob->maxcolgad = myCreateGadget (TEXT_KIND, gad, &ng,
652 GTTX_Text, (IPTR) glob->maxcolstr, GTTX_Clipped, TRUE,
653 (GadToolsBase->lib_Version >= 40) ? GTTX_Justification : TAG_IGNORE, GTJ_RIGHT, TAG_END);
655 top += ng.ng_Height + spacing;
658 if (glob->flags & SCREQF_AUTOSCROLLGAD)
661 str = GetStr (glob->catalog, MSG_AUTOSCROLL);
662 glob->gadkey[CHECKBOX_AUTOSCROLL] = KeyFromStr (str, '_');
663 val = StrWidth_noloc (&glob->itxt, str) + 8;
664 InitNewGadget (&ng, leftoff + 2 + val, top + (checkskip - checkh + 1) / 2, checkw,
665 checkh, NULL, AUTOSCR);
666 gad = glob->checkboxgad[CHECKBOX_AUTOSCROLL] =
667 myCreateGadget (CHECKBOX_KIND, gad, &ng, GTCB_Scaled, TRUE,
668 GTCB_Checked, glob->autoscroll, TAG_END);
669 img = my_CreateGadgetLabelImage (img, &ng, str, leftoff + 2,
670 top + (checkskip - glob->fontheight + 1) / 2, TEXTPEN);
671 top += checkskip + spacing;
674 ng.ng_Flags = 0;
678 /* create buttons */
679 buttonheight = createstyle ? (checkskip + 4) : (glob->fontheight + 6);
680 ng.ng_TextAttr = &glob->font;
681 checkboxcount = CHECKBOX_BOLD;
683 for (i = 0; i < 8; i++)
686 if (i == num1)
688 if (createstyle || (isfilereq && (glob->flags & FREQF_MULTISELECT)))
689 top += buttonheight + spacing;
690 if (createstyle) buttonheight = (glob->fontheight + 6);
693 ng.ng_TopEdge = top;
694 ng.ng_LeftEdge = gadpos[i];
695 ng.ng_Width = gadlen[i];
696 ng.ng_Height = buttonheight;
697 ng.ng_GadgetText = gadtxt[i];
698 ng.ng_GadgetID = INFO + i;
700 if (!isfilereq)
702 if (isfontreq)
704 if ((i == 3) || (i == 5) || (i == 6)) continue;
705 if (i < 3)
707 if (createstyle)
710 check = FALSE;
712 switch (i)
714 case 0: check = (glob->fontstyle & FSF_BOLD); break;
715 case 1: check = (glob->fontstyle & FSF_ITALIC); break;
716 case 2: check = (glob->fontstyle & FSF_UNDERLINED); break;
719 glob->gadkey[i] = KeyFromStr (gadtxt[i], '_');
720 ng.ng_Width = checkw;
721 ng.ng_Height = checkh;
722 ng.ng_GadgetID = BOLD + i;
723 ng.ng_GadgetText = NULL;
724 ng.ng_LeftEdge += (2 - i);
725 img = my_CreateGadgetLabelImage (img, &ng, gadtxt[i],
726 ng.ng_LeftEdge, top + 2 + (checkskip - glob->fontheight + 1) / 2, TEXTPEN);
727 ng.ng_LeftEdge += gadlen[i] - checkw;
728 ng.ng_TopEdge += 2 + (checkskip - checkh + 1) / 2;
729 glob->checkboxgad[checkboxcount++] = gad = myCreateGadget
730 (CHECKBOX_KIND, gad, &ng, GTCB_Checked, check, GTCB_Scaled, TRUE, TAG_END);
732 continue;
736 } /* if (isfontreq) */
737 else if (i < 4 || i == 5 || i == 6) continue;
739 } /* if (!isfilereq) */
741 if (i == 0)
743 if (glob->flags & FREQF_MULTISELECT)
745 ng.ng_GadgetText = NULL;
746 gad = glob->numselectedgad =
747 myCreateGadget (TEXT_KIND, gad, &ng, GTTX_Border, TRUE, TAG_END);
750 else
752 if ((i > 3) || (glob->flags & FREQF_MULTISELECT))
753 gad = my_CreateButtonGadget (gad, (i == 4) ? glob->underchar : '_', &ng);
754 if (i == 4) glob->okgad = gad;
755 if (i == 7) glob->cancelgad = gad;
758 } /* for (i = 0; i < 8; i++) */
761 ng.ng_LeftEdge = ng.ng_TopEdge = ng.ng_Width = ng.ng_Height = 0;
762 ng.ng_GadgetText = NULL;
763 gad = myCreateGadget (GENERIC_KIND, gad, &ng, TAG_END);
765 if (gad)
767 gad->GadgetType |= GTYP_BOOLGADGET;
768 gad->Flags |= GFLG_GADGIMAGE|GFLG_GADGHNONE;
769 gad->GadgetRender = (APTR)glob->labelimages.NextImage;
771 if (glob->numselectedgad)
773 glob->selitxt.LeftEdge = glob->numselectedgad->LeftEdge + 8;
774 glob->selitxt.TopEdge = glob->numselectedgad->TopEdge + 3;
775 glob->selitxt.DrawMode = JAM1;
776 glob->selitxt.FrontPen = glob->pens[TEXTPEN];
777 glob->selitxt.IText = gadtxt[0];
778 glob->selitxt.ITextFont = &glob->font;
779 gad->GadgetText = &glob->selitxt;
780 glob->numselectedoff = IntuiTextLength (&glob->selitxt);
784 /* is the window being rebuild or do we open it for the first time? */
785 winheight = top + buttonheight + spacing + BottomBorderHeight (glob->scr);
786 if (!glob->reqwin)
788 glob->newreqwin.Width = winwidth;
789 glob->newreqwin.Height = winheight;
790 glob->newreqwin.IDCMPFlags = glob->shareidcmp ? 0 : REQ_IDCMP;
791 glob->newreqwin.Flags = WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
792 |WFLG_CLOSEGADGET|WFLG_SIZEBBOTTOM|WFLG_ACTIVATE
793 |WFLG_RMBTRAP|WFLG_SIMPLE_REFRESH;
794 glob->newreqwin.DetailPen = ( UBYTE ) -1; /* glob->pens[BACKGROUNDPEN]; */
795 glob->newreqwin.BlockPen = ( UBYTE ) -1; /* glob->pens[SHADOWPEN]; */
796 glob->newreqwin.Title = glob->title;
797 glob->newreqwin.LeftEdge = glob->leftedge;
798 glob->newreqwin.TopEdge = glob->topedge;
799 glob->newreqwin.MinWidth = glob->newreqwin.MaxWidth = winwidth;
800 glob->newreqwin.MinHeight = winheight;
802 if (glob->numentries > 3)
803 glob->newreqwin.MinHeight -= (glob->numentries - 3) * glob->entryheight;
805 glob->newreqwin.MaxHeight =
806 winheight + (50 - glob->numentries) * glob->entryheight;
808 reqpos = CheckReqPos (glob->reqpos, reqdefnum, &glob->newreqwin);
810 if (reqpos == REQPOS_POINTER)
812 glob->newreqwin.LeftEdge = -winwidth / 2;
813 glob->newreqwin.TopEdge = -winheight / 2;
816 rtSetReqPosition (reqpos, &glob->newreqwin, glob->scr, glob->prwin);
818 glob->zoom[2] = glob->newreqwin.MinWidth;
819 glob->zoom[3] = glob->newreqwin.MinHeight;
821 if (!img || !gad || !(glob->reqwin = OpenWindowBF (&glob->newreqwin,
822 &glob->backfillhook, glob->pens, &glob->rpmask, glob->zoom, FALSE)))
824 my_FreeGadgets (glob->buttoninfo.glist);
825 glob->buttoninfo.glist = NULL;
826 my_FreeLabelImages (&glob->labelimages);
827 glob->labelimages.NextImage = NULL;
829 if (gad && img && (glob->numentries > 3))
831 glob->numentries--;
832 goto retryopenwindow;
835 return (FALSE);
838 glob->buttoninfo.win = glob->reqwin;
840 glob->winaddr = (struct Window **)&(ThisProcess()->pr_WindowPtr);
841 glob->oldwinptr = *glob->winaddr;
842 *glob->winaddr = glob->reqwin;
844 if (glob->shareidcmp)
846 glob->reqwin->UserPort = glob->prwin->UserPort;
847 ModifyIDCMP (glob->reqwin, REQ_IDCMP);
850 glob->fnamegaduserdata.msgport = glob->reqwin->UserPort;
851 glob->timereq.tr_node.io_Message.mn_ReplyPort = glob->reqwin->UserPort;
853 if ((WorkbenchBase = OpenLibrary ("workbench.library", 0)))
855 if ((glob->appwinport = CreateMsgPort()))
857 glob->appwindow = AddAppWindowA (0, 0, glob->reqwin, glob->appwinport, NULL);
861 maxpen = 0;
862 for (i = 0; scrollpens[i] >= 0; i++)
863 if (glob->pens[scrollpens[i]] > maxpen)
864 maxpen = glob->pens[scrollpens[i]];
865 mask = 1;
866 while (mask < maxpen)
868 mask <<= 1;
869 mask |= 1;
871 glob->entrymask = mask;
873 else
875 if (!img || !gad)
877 my_FreeGadgets (glob->buttoninfo.glist);
878 glob->buttoninfo.glist = NULL;
879 my_FreeLabelImages (&glob->labelimages);
880 glob->labelimages.NextImage = NULL;
881 return (FALSE);
884 RefreshWindowFrame (glob->reqwin);
885 SetAPen (glob->reqrp, glob->pens[BACKGROUNDPEN]);
886 RectFill (glob->reqrp, glob->reqwin->BorderLeft,
887 glob->reqwin->BorderTop,
888 glob->reqwin->Width - glob->reqwin->BorderRight - 1,
889 glob->reqwin->Height - glob->reqwin->BorderBottom - 1);
892 ((FI_REQ)glob->req)->ReqHeight = winheight;
894 if (glob->filegad)
895 glob->filestr = ((struct StringInfo *)glob->filegad->SpecialInfo)->Buffer;
897 glob->reqrp = glob->reqwin->RPort;
898 SetFont (glob->reqrp, glob->reqfont);
899 AddGList (glob->reqwin, glob->buttoninfo.glist, -1L, -1L, NULL);
900 RefreshGList (glob->buttoninfo.glist, glob->reqwin, NULL, -1L);
901 GT_RefreshWindow (glob->reqwin, NULL);
903 glob->activegadget = glob->mainstrgad;
905 return (1);
908 /****************************************************************************************/