2 // Popup Menu Window funcs
3 // ©1996-2002 Henrik Isaksson
9 // Allocate memory and copy a RastPort structure
11 struct RastPort
*PM_CpyRPort(struct RastPort
*rp
)
15 rpc
=PM_Mem_Alloc(sizeof(struct RastPort
));
17 CopyMem(rp
, rpc
, sizeof(struct RastPort
));
24 // Copy the region beneath a window to the transparency buffer.
26 void PM_TransparencyBfr(struct PM_Window
*bw
)
29 ULONG transparent
= FALSE
;
32 GetGUIAttrs(NULL
, bw
->p
->DrawInfo
, GUIA_MenuTransparency
, &transparent
, TAG_DONE
);
35 if(CyberGfx
&& transparent
) {
36 if(GetCyberMapAttr(bw
->Wnd
->WScreen
->RastPort
.BitMap
, CYBRMATTR_ISCYBERGFX
)) {
37 bpp
= GetCyberMapAttr(bw
->Wnd
->WScreen
->RastPort
.BitMap
, CYBRMATTR_BPPIX
);
42 // If we've gotten this far, the screen is CyberGfx and > 15 bpp
44 bw
->bg
.BgArray
= PM_Mem_Alloc(3 * bw
->Width
* bw
->Height
);
46 ReadPixelArray(bw
->bg
.BgArray
, 0, 0,
47 bw
->Width
* 3, bw
->RPort
, 0, 0,
48 bw
->Width
, bw
->Height
, RECTFMT_RGB
);
49 // Fast and simple way to blend the background to gray...
50 for(j
= 0; j
< bw
->Width
* bw
->Height
* 3; j
++) {
51 bw
->bg
.BgArray
[j
] = (bw
->bg
.BgArray
[j
]>>2) + 150;
58 // Create an offscreen buffer for rendering animation and transition
61 void PM_OffScreenBfr(struct PM_Window
*bw
)
63 if(PM_Prefs
->pmp_Animation
) {
64 bw
->te
.BMap
=AllocBitMap(bw
->Width
, bw
->Height
, bw
->Wnd
->WScreen
->RastPort
.BitMap
->Depth
, BMF_MINPLANES
, bw
->Wnd
->WScreen
->RastPort
.BitMap
);
66 bw
->te
.RPort
=PM_CpyRPort(&bw
->Wnd
->WScreen
->RastPort
);
68 bw
->te
.RPort
->Layer
= NULL
; /* huuu! */
69 bw
->te
.RPort
->BitMap
= bw
->te
.BMap
;
78 BOOL
PM_OpenWindow(struct PM_Window
*pw
, int left
, int top
, int width
, int height
, struct Screen
*scr
)
80 pw
->bg
.BgArray
= NULL
;
83 pw
->Wnd
= OpenWindowTags(NULL
,
90 //WA_ReportMouse, TRUE,
92 //WA_IDCMP, IDCMP_CLOSEWINDOW, // Kommer aldrig att inträffa - anv. för resize
93 WA_SmartRefresh
, TRUE
,
94 WA_BackFill
, LAYERS_NOBACKFILL
,
98 pw
->RPort
= pw
->Wnd
->RPort
;
100 /* Transparency/background image */
101 PM_TransparencyBfr(pw
);
103 /* Transition effects */
116 void PM_CloseWindow(struct PM_Window
*bw
)
118 if(bw
->bg
.BgArray
) PM_Mem_Free(bw
->bg
.BgArray
);
119 if(bw
->te
.RPort
) PM_Mem_Free(bw
->te
.RPort
);
120 if(bw
->te
.BMap
) FreeBitMap(bw
->te
.BMap
);
121 if(bw
->Wnd
) CloseWindow(bw
->Wnd
);
123 bw
->bg
.BgArray
= NULL
;
132 void PM_ResizeWindow(struct PM_Window
*bw
, int l
, int t
, int w
, int h
)
136 if(l
==bw
->Wnd
->LeftEdge
&& t
==bw
->Wnd
->TopEdge
&& w
==bw
->Width
&& h
==bw
->Height
)
137 return; // If no change
139 ModifyIDCMP(bw
->Wnd
, IDCMP_CLOSEWINDOW
|IDCMP_NEWSIZE
);
140 ChangeWindowBox(bw
->Wnd
, l
, t
, w
, h
);
141 WaitPort(bw
->Wnd
->UserPort
);
142 while((msg
=GetMsg(bw
->Wnd
->UserPort
))) ReplyMsg(msg
);
143 ModifyIDCMP(bw
->Wnd
, IDCMP_CLOSEWINDOW
);
145 // bw->Width=bw->wnd->Width;
146 // bw->Height=bw->wnd->Height;
150 // Find out if we should close our submenu
154 // PM_InsideWindows(px, py, wnd)
156 // px, py - Screen coords
160 BOOL
PM_InsideWindows(int px
, int py
, struct PM_Window
*wnd
)
170 if(px
> w
->Wnd
->LeftEdge
+ w
->Selected
->Left
- 2 &&
171 px
< w
->Wnd
->LeftEdge
+ w
->Selected
->Left
+ w
->Selected
->Width
+ 2 &&
172 py
> w
->Wnd
->TopEdge
+ w
->Selected
->Top
- 2 &&
173 py
< w
->Wnd
->TopEdge
+ w
->Selected
->Top
+ w
->Selected
->Height
+ 2)
179 if(x
> w
->Wnd
->LeftEdge
&&
180 y
>= w
->Wnd
->TopEdge
&&
181 x
< w
->Wnd
->LeftEdge
+ w
->Width
&&
182 y
< w
->Wnd
->TopEdge
+ w
->Height
) {