2 Copyright © 1995-2007, 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 *****************************************************************************/
79 struct Screen
*scr
= NULL
, *lockedscr
= NULL
;
81 //struct Gadget *gadgets;
83 //STRPTR gadgetlabels[3];
84 struct IntRequestUserData
*requserdata
;
87 DEBUG_BUILDSYSREQUEST(dprintf("intrequest_buildsysrequest: window 0x%lx body <%s> postext <%s> negtext <%s> IDCMPFlags 0x%lx width %ld height %ld\n",
89 bodytext
? (char *) bodytext
->IText
: "<NULL>",
90 postext
->IText
? (char *) postext
->IText
: "<NULL>",
91 negtext
->IText
? (char *) negtext
->IText
: "<NULL>",
96 /* negtext and bodytest must be specified, postext is optional */
97 if (!negtext
|| !bodytext
) return NULL
;
99 /* get requester title */
102 if (window
) reqtitle
= window
->Title
;
103 if (!reqtitle
) reqtitle
= "System Request"; /* stegerg: should be localized */
105 /* get screen and screendrawinfo */
107 scr
= window
->WScreen
;
110 scr
= LockPubScreen(NULL
);
116 requserdata
= AllocVec(sizeof (struct IntRequestUserData
),MEMF_PUBLIC
|MEMF_CLEAR
);
117 if (!requserdata
) goto fail
;
119 requserdata
->ReqScreen
= scr
;
121 negtextlen
= strlen(negtext
->IText
) + 1;
125 int postextlen
= strlen(postext
->IText
) + 1;
127 requserdata
->NumGadgets
= 2;
128 requserdata
->GadgetLabels
= AllocVec((requserdata
->NumGadgets
+ 1) * sizeof(STRPTR
), MEMF_PUBLIC
|MEMF_CLEAR
);
129 if (!requserdata
->GadgetLabels
) goto fail
;
130 requserdata
->GadgetLabels
[0] = AllocVec(postextlen
+ negtextlen
, MEMF_PUBLIC
);
131 if (!requserdata
->GadgetLabels
[0])
133 FreeVec(requserdata
->GadgetLabels
); goto fail
;
135 CopyMem(postext
->IText
,requserdata
->GadgetLabels
[0], postextlen
);
136 requserdata
->GadgetLabels
[1] = requserdata
->GadgetLabels
[0] + postextlen
;
137 CopyMem(negtext
->IText
,requserdata
->GadgetLabels
[1], negtextlen
);
139 requserdata
->NumGadgets
= 1;
140 requserdata
->GadgetLabels
= AllocVec((requserdata
->NumGadgets
+ 1) * sizeof(STRPTR
), MEMF_PUBLIC
|MEMF_CLEAR
);
141 if (!requserdata
->GadgetLabels
) goto fail
;
142 requserdata
->GadgetLabels
[0] = AllocVec(negtextlen
, MEMF_PUBLIC
);
143 if (!requserdata
->GadgetLabels
[0])
145 FreeVec(requserdata
->GadgetLabels
); goto fail
;
147 CopyMem(negtext
->IText
,requserdata
->GadgetLabels
[0], negtextlen
);
150 /* create everything */
152 requserdata
->Text
= bodytext
;
155 struct IntuiText
*it
= bodytext
;
158 requserdata
->NumLines
++;
163 requserdata
->ReqGadgets
= AllocVec(requserdata
->NumGadgets
* (sizeof (struct RequesterGadget
)),MEMF_PUBLIC
);
164 if (!requserdata
->ReqGadgets
) goto fail
;
166 intrequest_layoutrequester(requserdata
,IntuitionBase
);
167 if (!requserdata
->wwidth
) goto fail
;
169 if (!(intrequest_creategadgets(requserdata
,IntuitionBase
))) goto fail
;
172 struct TagItem win_tags
[] =
174 { WA_Width
, requserdata
->wwidth
},
175 { WA_Height
, requserdata
->wheight
},
176 { WA_Left
, (scr
->Width
/2) - (requserdata
->wwidth
/2) },
177 { WA_Top
, (scr
->Height
/2) - (requserdata
->wheight
/2) },
178 { WA_IDCMP
, IDCMP_GADGETUP
| IDCMP_RAWKEY
| (IDCMPFlags
& ~IDCMP_VANILLAKEY
) | IDCMP_REFRESHWINDOW
},
179 { WA_Gadgets
, (IPTR
)requserdata
->Gadgets
},
180 { WA_Title
, (IPTR
)reqtitle
},
181 { (lockedscr
? WA_PubScreen
: WA_CustomScreen
), (IPTR
)scr
},
182 { WA_Flags
, WFLG_DRAGBAR
|
185 WFLG_SIMPLE_REFRESH
|
187 { WA_SkinInfo
, NULL
},
191 req
= OpenWindowTagList(NULL
, win_tags
);
197 if (lockedscr
) UnlockPubScreen(NULL
, lockedscr
);
199 req
->UserData
= (BYTE
*)requserdata
;
200 requserdata
->IDCMP
= IDCMPFlags
;
201 requserdata
->ReqWindow
= req
;
203 intrequest_drawrequester(requserdata
,IntuitionBase
);
212 intrequest_freegadgets(requserdata
->Gadgets
,IntuitionBase
);
213 intrequest_freelabels(requserdata
->GadgetLabels
, IntuitionBase
);
214 if (requserdata
->dri
) FreeScreenDrawInfo(requserdata
->ReqScreen
,(struct DrawInfo
*)requserdata
->dri
);
215 if (requserdata
->freeitext
) intrequest_freeitext(requserdata
->Text
,IntuitionBase
);
216 if (requserdata
->ReqGadgets
) FreeVec(requserdata
->ReqGadgets
);
217 FreeVec(requserdata
);
220 if (lockedscr
) UnlockPubScreen(NULL
, lockedscr
);
226 } /* BuildSysRequest */
228 /**********************************************************************************************/