2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
9 #include <proto/utility.h>
10 #include <proto/intuition.h>
11 #include <proto/graphics.h>
13 #include <intuition/intuition.h>
14 #include "asl_intern.h"
16 struct LayoutData
*AllocCommon(ULONG
, struct IntReq
*, APTR
, struct AslBase_intern
*);
17 VOID
FreeCommon(struct LayoutData
*, struct AslBase_intern
*);
18 BOOL
HandleEvents(struct LayoutData
*, struct AslReqInfo
*, struct AslBase_intern
*);
25 # include <aros/debug.h>
27 /*****************************************************************************
30 #include <proto/asl.h>
31 #include <utility/tagitem.h>
33 AROS_LH2(BOOL
, AslRequest
,
36 AROS_LHA(APTR
, requester
, A0
),
37 AROS_LHA(struct TagItem
*, tagList
, A1
),
40 struct Library
*, AslBase
, 10, Asl
)
59 27-11-96 digulla automatically created from
60 asl_lib.fd and clib/asl_protos.h
62 *****************************************************************************/
66 struct ReqNode
*reqnode
;
67 struct IntReq
*intreq
;
68 struct AslReqInfo
*reqinfo
;
69 struct LayoutData
*ld
;
75 D(bug("AslRequest(requester=%p, tagList=%p)\n", requester
, tagList
));
79 SetIoErr(ERROR_NO_FREE_STORE
);
83 /* Find the correspondent internal structure */
84 reqnode
= FindReqNode(requester
, ASLB(AslBase
));
90 intreq
= reqnode
->rn_IntReq
;
91 reqinfo
= &(ASLB(AslBase
)->ReqInfo
[intreq
->ir_ReqType
]);
93 /* stegerg: this must be done when the Requester is terminated
94 ** before setting the new output variables in the Requester struct.
96 ** StripRequester(requester, intreq->ir_ReqType, ASLB(AslBase));
99 /* Parse new tags if supplied */
102 struct ParseTagArgs pta
;
104 ParseCommonTags(intreq
, tagList
, ASLB(AslBase
));
106 /* Parse requester specific tags */
107 pta
.pta_IntReq
= intreq
;
108 pta
.pta_Req
= reqnode
->rn_Req
;
109 pta
.pta_Tags
= tagList
;
111 CallHookPkt(&(reqinfo
->ParseTagsHook
), &pta
, ASLB(AslBase
));
114 /* Now do the layout stuff */
117 /* Do some allocations common for all requesters */
118 ld
= AllocCommon(reqinfo
->UserDataSize
, intreq
, requester
, ASLB(AslBase
));
121 D(bug("Common stuff allocated\n"));
123 /* Tell the specific requester to initialize */
125 ld
->ld_Command
= LDCMD_INIT
;
127 if (CallHookPkt( &(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
)))
130 struct TagItem wintags
[] =
132 {WA_CustomScreen
, (IPTR
)ld
->ld_Screen
}, /* stegerg: requesters should not use WA_PubScreen */
133 {WA_InnerWidth
, 0 },
134 {WA_InnerHeight
, 0 },
135 {WA_AutoAdjust
, TRUE
},
136 {WA_NewLookMenus
, TRUE
},
138 {WA_BackFill
, (IPTR
)LAYERS_NOBACKFILL
},
145 memset(&nw
, 0L, sizeof (struct NewWindow
));
147 nw
.Width
= (intreq
->ir_Width
> ld
->ld_MinWidth
) ? intreq
->ir_Width
: ld
->ld_MinWidth
;
148 nw
.Height
= (intreq
->ir_Height
> ld
->ld_MinHeight
) ? intreq
->ir_Height
: ld
->ld_MinHeight
;
150 if (intreq
->ir_LeftEdge
>= 0)
152 nw
.LeftEdge
= intreq
->ir_LeftEdge
;
154 nw
.LeftEdge
= (ld
->ld_Screen
->ViewPort
.DWidth
- (nw
.Width
+ ld
->ld_WBorLeft
+ ld
->ld_WBorRight
)) / 2
155 - ld
->ld_Screen
->LeftEdge
;
157 if (intreq
->ir_TopEdge
>= 0)
159 nw
.TopEdge
= intreq
->ir_TopEdge
;
161 nw
.TopEdge
= (ld
->ld_Screen
->ViewPort
.DHeight
- (nw
.Height
+ ld
->ld_WBorTop
+ ld
->ld_WBorBottom
)) / 2
162 - ld
->ld_Screen
->TopEdge
;
165 D(bug("MinWidth: %d, MinHeight: %d\n", ld
->ld_MinWidth
, ld
->ld_MinHeight
));
167 nw
.Title
= intreq
->ir_TitleText
;
170 nw
.Title
= GetString(intreq
->ir_TitleID
, intreq
->ir_Catalog
, ASLB(AslBase
));
173 D(bug("\tWindow title: %s", nw
.Title
));
175 /* nw.FirstGadget = ld->ld_GList;
177 nw
.Flags
= WFLG_DRAGBAR
| WFLG_DEPTHGADGET
| WFLG_CLOSEGADGET
|
178 WFLG_SIZEGADGET
| WFLG_SIZEBBOTTOM
| WFLG_SIMPLE_REFRESH
|
181 if (!(intreq
->ir_Flags
& IF_OPENINACTIVE
))
183 nw
.Flags
|= WFLG_ACTIVATE
;
186 idcmp
= IDCMP_CLOSEWINDOW
| IDCMP_GADGETUP
| IDCMP_MOUSEMOVE
|
187 IDCMP_NEWSIZE
| IDCMP_REFRESHWINDOW
| IDCMP_GADGETDOWN
|
188 IDCMP_MENUPICK
| IDCMP_RAWKEY
| IDCMP_VANILLAKEY
|
191 wintags
[1].ti_Data
= nw
.Width
;
192 wintags
[2].ti_Data
= nw
.Height
;
194 privateidcmp
= ((intreq
->ir_Flags
& IF_PRIVATEIDCMP
) || (!intreq
->ir_Window
));
197 nw
.IDCMPFlags
= idcmp
;
200 win
= OpenWindowTagList(&nw
, wintags
);
205 win
->UserPort
= intreq
->ir_Window
->UserPort
;
206 ModifyIDCMP(win
, idcmp
);
211 ObtainSemaphore( &(ASLB(AslBase
)->ReqListSem
) );
212 reqnode
->rn_ReqWindow
= win
;
213 ReleaseSemaphore(&(ASLB(AslBase
)->ReqListSem
));
215 D(bug("Window opened\n"));
219 "\tLeft: %d\n\tTop: %d\n\tWidth: %d\n\tHeight: %d\n",
227 /* Constraint the window minsize */
232 ld
->ld_MinWidth
+ win
->BorderLeft
+ win
->BorderRight
,
233 ld
->ld_MinHeight
+ win
->BorderTop
+ win
->BorderBottom
,
238 D(bug("Window limits set\n"));
240 SetFont(win
->RPort
, ld
->ld_Font
);
242 /* Layout the requester */
243 ld
->ld_Command
= LDCMD_LAYOUT
;
244 if (CallHookPkt(&(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
)))
246 D(bug("Gadgetry layout done\n"));
250 D(bug("Adding glist\n"));
251 AddGList(win
, ld
->ld_GList
, -1, -1, NULL
);
252 D(bug("Refreshing glist\n"));
253 RefreshGList(ld
->ld_GList
, win
, NULL
, -1);
255 D(bug("Gadgetlist refreshed\n"));
258 if (ld
->ld_Menu
) SetMenuStrip(win
, ld
->ld_Menu
);
260 ld
->ld_Command
= LDCMD_WINDOWOPENED
;
261 CallHookPkt(&(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
));
263 if (intreq
->ir_Flags
& IF_POPTOFRONT
)
265 struct Screen
*frontscr
;
268 ilock
= LockIBase(0);
269 frontscr
= IntuitionBase
->FirstScreen
;
272 if (frontscr
!= win
->WScreen
)
274 ScreenToFront(win
->WScreen
);
275 intreq
->ir_Flags
|= IF_POPPEDTOFRONT
;
279 /* Wait for the user to do something */
280 success
= HandleEvents(ld
, reqinfo
, ASLB(AslBase
));
282 /* Finished with event handling, clean up requester
285 ld
->ld_Command
= LDCMD_CLEANUP
;
286 CallHookPkt(&(reqinfo
->GadgetryHook
), ld
, ASLB(AslBase
));
288 } /* if (CallHookPkt(&(reqinfo->GadgetryHook), ld, ASLB(AslBase))) */
290 /* win is closed in FreeCommon */
294 } /* if (CallHookPkt( &(reqinfo->GadgetryHook), ld, ASLB(AslBase))) */
296 ObtainSemaphore( &(ASLB(AslBase
)->ReqListSem
) );
297 reqnode
->rn_ReqWindow
= NULL
;
298 ReleaseSemaphore(&(ASLB(AslBase
)->ReqListSem
));
300 FreeCommon(ld
, ASLB(AslBase
));
304 ReturnBool ("AslRequest", success
);