1 /**************************************************************
3 * File/Font/Screenmode requester *
5 * (c) Nico François 1991-1994 *
6 **************************************************************/
10 /****************************************************************************************/
12 /***************************
14 * REQUESTER WINDOW SETUP *
16 ***************************/
18 /****************************************************************************************/
20 static void REGARGS
CheckGadgetsSize (ULONG
*gadlen
, ULONG
*width
, ULONG availwidth
, ULONG num
)
25 if (availwidth
>= *width
) return;
27 overlap
= ((((*width
- availwidth
) << 16) / num
) + 0xffff) >> 16;
28 for (i
= 0; i
< num
; i
++)
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
)
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
)
58 GT_BeginRefresh (glob
->reqwin
);
61 if (glob
->numselectedgad
)
62 UpdateNumSelGad (glob
);
64 if (glob
->reqtype
== RT_FONTREQ
)
65 ShowFontSample (glob
, refresh
, dowait
);
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
)
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
;
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
;
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
)
121 if (isvolreq
) reqdefnum
= RTPREF_VOLUMEREQ
;
122 else reqdefnum
= RTPREF_FILEREQ
;
126 reqdefnum
= RTPREF_FONTREQ
;
129 case RT_SCREENMODEREQ
:
130 reqdefnum
= RTPREF_SCREENMODEREQ
;
135 leftoff
= glob
->scr
->WBorLeft
+ 5;
136 rightoff
= glob
->scr
->WBorRight
+ 5;
137 totaloff
= (leftoff
+ rightoff
);
141 reqdefs
= &rtLockPrefs()->ReqDefaults
[reqdefnum
];
143 if (!glob
->reqheight
)
145 glob
->reqheight
= ((int)reqdefs
->Size
* scrheight
) / 100;
149 if (glob
->reqheight
> scrheight
) glob
->reqheight
= scrheight
;
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
;
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
;
176 val
= stdgadheight
* 2 + spacing
* 3 + spacing
/ 2 + 8 + glob
->sampleheight
;
177 if (createstyle
) val
+= checkskip
+ 4 + spacing
;
181 val
= (stdgadheight
+ spacing
) * 2 + spacing
/ 2 + 4;
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
;
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
;
215 val
= !defaultheight
? 50 : reqdefs
->MaxEntries
;
216 if (glob
->numentries
> val
) glob
->numentries
= val
;
221 /* calculate width of gadgets and window */
222 gadtxt
[7] = GetStr (glob
->catalog
, MSG_CANCEL
);
224 if (isfilereq
|| isfontreq
)
226 for (i
= 0; i
< 4; i
++) gadlen
[i
] = 0;
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
);
243 gadtxt
[5] = GetStr (glob
->catalog
, MSG_VOLUMES
);
244 gadtxt
[6] = GetStr (glob
->catalog
, MSG_PARENT
);
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;
257 /* Calculate width of top row of gadgets */
259 for (i
= 0; i
< num1
; i
++)
261 gadlen
[i
] += StrWidth_noloc (&glob
->itxt
, gadtxt
[i
]) + 16;
267 /* isvolreq or screenmode request */
271 if (num2
== 2) gadtxt
[5] = gadtxt
[7];
274 /* Calculate width of button row of gadgets */
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
;
285 if (isfilereq
&& !(glob
->flags
& FREQF_MULTISELECT
)) width1
= 0;
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
);
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
;
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
);
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
);
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 */
367 InitNewGadget (&ng
, leftoff
+ 4, top
+ 2,
368 winwidth
- 26 - totaloff
, glob
->boxheight
, NULL
, FILES
);
370 gad
= myCreateGadget (GENERIC_KIND
, gad
, &ng
, TAG_END
);
373 gad
->GadgetType
|= GTYP_BOOLGADGET
;
374 gad
->Flags
|= GFLG_GADGHNONE
;
375 gad
->Activation
|= GACT_IMMEDIATE
|GACT_FOLLOWMOUSE
|GACT_RELVERIFY
;
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
,
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 */
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
);
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;
434 str
= GetStr (glob
->catalog
, MSG_GET
);
435 val
= StrWidth_noloc (&glob
->itxt
, str
) + 8;
437 if (val
> dotinfowidth
) dotinfowidth
= val
;
440 InitNewGadget (&ng
, winwidth
- rightoff
- val
, top
, val
,
441 stdgadheight
, str
, GETDIR
);
442 gad
= my_CreateButtonGadget (gad
, '_', &ng
);
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
);
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
))
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
);
477 gad
->Activation
|= GACT_TOGGLESELECT
;
478 if (!glob
->freq
->hideinfo
) gad
->Flags
|= GFLG_SELECTED
;
481 top
+= ng
.ng_Height
+ spacing
;
485 glob
->filegad
= NULL
;
486 glob
->mainstrgad
= glob
->drawergad
;
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) */
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
;
525 * ScreenMode Requester gadgets
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
,
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
,
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
,
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
;
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
)
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
);
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
;
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
++)
688 if (createstyle
|| (isfilereq
&& (glob
->flags
& FREQF_MULTISELECT
)))
689 top
+= buttonheight
+ spacing
;
690 if (createstyle
) buttonheight
= (glob
->fontheight
+ 6);
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
;
704 if ((i
== 3) || (i
== 5) || (i
== 6)) continue;
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
);
736 } /* if (isfontreq) */
737 else if (i
< 4 || i
== 5 || i
== 6) continue;
739 } /* if (!isfilereq) */
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
);
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
);
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
);
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))
832 goto retryopenwindow
;
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
);
862 for (i
= 0; scrollpens
[i
] >= 0; i
++)
863 if (glob
->pens
[scrollpens
[i
]] > maxpen
)
864 maxpen
= glob
->pens
[scrollpens
[i
]];
866 while (mask
< maxpen
)
871 glob
->entrymask
= mask
;
877 my_FreeGadgets (glob
->buttoninfo
.glist
);
878 glob
->buttoninfo
.glist
= NULL
;
879 my_FreeLabelImages (&glob
->labelimages
);
880 glob
->labelimages
.NextImage
= NULL
;
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
;
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
;
908 /****************************************************************************************/