2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #define DEBUG_BUILDSYSREQUEST(x) ;
9 /**********************************************************************************************/
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
13 #include <proto/graphics.h>
17 #include <clib/macros.h>
18 #include <exec/memory.h>
19 #include <intuition/gadgetclass.h>
20 #include <intuition/imageclass.h>
21 #include <intuition/screens.h>
22 #include <graphics/rastport.h>
23 #include <graphics/gfxmacros.h>
24 #include <utility/tagitem.h>
25 #include "intuition_intern.h"
26 #include "requesters.h"
28 /**********************************************************************************************
31 #include <proto/intuition.h>
32 #include <exec/types.h>
33 #include <intuition/intuition.h>
35 AROS_LH7(struct Window
*, BuildSysRequest
,
38 AROS_LHA(struct Window
* , window
, A0
),
39 AROS_LHA(struct IntuiText
*, bodytext
, A1
),
40 AROS_LHA(struct IntuiText
*, postext
, A2
),
41 AROS_LHA(struct IntuiText
*, negtext
, A3
),
42 AROS_LHA(ULONG
, IDCMPFlags
, D0
),
43 AROS_LHA(WORD
, width
, D2
),
44 AROS_LHA(WORD
, height
, D3
),
47 struct IntuitionBase
*, IntuitionBase
, 60, Intuition
)
52 window - The window in which the requester will appear
53 bodytext - The Text to be shown in the body of the requester
54 postext - The Text to be shown in the positive choice gadget
55 negtext - The Text to be shown in the negative choice gadget
56 IDCMPFlags - The IDCMP Flags for this requester
57 width, height - The dimensions of the requester
68 FreeSysRequest(), DisplayAlert(), ModifyIDCMP(), exec-library/Wait(),
69 Request(), AutoRequest(), EasyRequest(), BuildEasyRequestArgs()
75 *****************************************************************************/
78 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
80 struct Screen
*scr
= NULL
, *lockedscr
= NULL
;
82 //struct Gadget *gadgets;
84 //STRPTR gadgetlabels[3];
85 struct IntRequestUserData
*requserdata
;
88 DEBUG_BUILDSYSREQUEST(dprintf("intrequest_buildsysrequest: window 0x%lx body <%s> postext <%s> negtext <%s> IDCMPFlags 0x%lx width %ld height %ld\n",
90 bodytext
? (char *) bodytext
->IText
: "<NULL>",
91 postext
->IText
? (char *) postext
->IText
: "<NULL>",
92 negtext
->IText
? (char *) negtext
->IText
: "<NULL>",
97 /* negtext and bodytest must be specified, postext is optional */
98 if (!negtext
|| !bodytext
) return NULL
;
100 /* get requester title */
103 if (window
) reqtitle
= window
->Title
;
104 if (!reqtitle
) reqtitle
= "System Request"; /* stegerg: should be localized */
106 /* get screen and screendrawinfo */
108 scr
= window
->WScreen
;
111 scr
= LockPubScreen(NULL
);
117 requserdata
= AllocVec(sizeof (struct IntRequestUserData
),MEMF_PUBLIC
|MEMF_CLEAR
);
118 if (!requserdata
) goto fail
;
120 requserdata
->ReqScreen
= scr
;
122 negtextlen
= strlen(negtext
->IText
) + 1;
126 int postextlen
= strlen(postext
->IText
) + 1;
128 requserdata
->NumGadgets
= 2;
129 requserdata
->GadgetLabels
= AllocVec((requserdata
->NumGadgets
+ 1) * sizeof(STRPTR
), MEMF_PUBLIC
|MEMF_CLEAR
);
130 if (!requserdata
->GadgetLabels
) goto fail
;
131 requserdata
->GadgetLabels
[0] = AllocVec(postextlen
+ negtextlen
, MEMF_PUBLIC
);
132 if (!requserdata
->GadgetLabels
[0])
134 FreeVec(requserdata
->GadgetLabels
); goto fail
;
136 CopyMem(postext
->IText
,requserdata
->GadgetLabels
[0], postextlen
);
137 requserdata
->GadgetLabels
[1] = requserdata
->GadgetLabels
[0] + postextlen
;
138 CopyMem(negtext
->IText
,requserdata
->GadgetLabels
[1], negtextlen
);
140 requserdata
->NumGadgets
= 1;
141 requserdata
->GadgetLabels
= AllocVec((requserdata
->NumGadgets
+ 1) * sizeof(STRPTR
), MEMF_PUBLIC
|MEMF_CLEAR
);
142 if (!requserdata
->GadgetLabels
) goto fail
;
143 requserdata
->GadgetLabels
[0] = AllocVec(negtextlen
, MEMF_PUBLIC
);
144 if (!requserdata
->GadgetLabels
[0])
146 FreeVec(requserdata
->GadgetLabels
); goto fail
;
148 CopyMem(negtext
->IText
,requserdata
->GadgetLabels
[0], negtextlen
);
151 /* create everything */
153 requserdata
->Text
= bodytext
;
156 struct IntuiText
*it
= bodytext
;
159 requserdata
->NumLines
++;
164 requserdata
->ReqGadgets
= AllocVec(requserdata
->NumGadgets
* (sizeof (struct RequesterGadget
)),MEMF_PUBLIC
);
165 if (!requserdata
->ReqGadgets
) goto fail
;
167 intrequest_layoutrequester(requserdata
,IntuitionBase
);
168 if (!requserdata
->wwidth
) goto fail
;
170 if (!(intrequest_creategadgets(requserdata
,IntuitionBase
))) goto fail
;
173 struct TagItem win_tags
[] =
175 { WA_Width
, requserdata
->wwidth
},
176 { WA_Height
, requserdata
->wheight
},
177 { WA_Left
, (scr
->Width
/2) - (requserdata
->wwidth
/2) },
178 { WA_Top
, (scr
->Height
/2) - (requserdata
->wheight
/2) },
179 { WA_IDCMP
, IDCMP_GADGETUP
| IDCMP_RAWKEY
| (IDCMPFlags
& ~IDCMP_VANILLAKEY
) | IDCMP_REFRESHWINDOW
},
180 { WA_Gadgets
, (IPTR
)requserdata
->Gadgets
},
181 { WA_Title
, (IPTR
)reqtitle
},
182 { (lockedscr
? WA_PubScreen
: WA_CustomScreen
), (IPTR
)scr
},
183 { WA_Flags
, WFLG_DRAGBAR
|
186 WFLG_SIMPLE_REFRESH
|
188 { WA_SkinInfo
, NULL
},
192 req
= OpenWindowTagList(NULL
, win_tags
);
198 if (lockedscr
) UnlockPubScreen(NULL
, lockedscr
);
200 req
->UserData
= (BYTE
*)requserdata
;
201 requserdata
->IDCMP
= IDCMPFlags
;
202 requserdata
->ReqWindow
= req
;
204 intrequest_drawrequester(requserdata
,IntuitionBase
);
213 intrequest_freegadgets(requserdata
->Gadgets
,IntuitionBase
);
214 intrequest_freelabels(requserdata
->GadgetLabels
, IntuitionBase
);
215 if (requserdata
->dri
) FreeScreenDrawInfo(requserdata
->ReqScreen
,(struct DrawInfo
*)requserdata
->dri
);
216 if (requserdata
->freeitext
) intrequest_freeitext(requserdata
->Text
,IntuitionBase
);
217 if (requserdata
->ReqGadgets
) FreeVec(requserdata
->ReqGadgets
);
218 FreeVec(requserdata
);
221 if (lockedscr
) UnlockPubScreen(NULL
, lockedscr
);
227 } /* BuildSysRequest */
229 /**********************************************************************************************/