3 #include <intuition/intuition.h>
4 #include <graphics/gfx.h>
5 #include <proto/exec.h>
7 #include <proto/graphics.h>
8 #include <proto/intuition.h>
9 #include <clib/alib_protos.h>
10 #include <aros/debug.h>
16 #define INSTALL_NULL_SHAPE_FIRST 0
21 /***********************************************************************************/
23 struct IntuitionBase
*IntuitionBase
;
24 struct GfxBase
*GfxBase
;
29 struct Hook shapehook
;
33 /***********************************************************************************/
35 static void cleanup(char *msg
)
39 printf("roundshape: %s\n",msg
);
42 if (win
) CloseWindow(win
);
43 if (shape
) DisposeRegion(shape
);
44 if (scr
) UnlockPubScreen(0, scr
);
46 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
47 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
52 /***********************************************************************************/
54 static void openlibs(void)
56 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
58 cleanup("Can't open intuition.library V39!");
61 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
63 cleanup("Can't open graphics.library V39!");
68 /***********************************************************************************/
70 static void getvisual(void)
72 if (!(scr
= LockPubScreen(NULL
)))
74 cleanup("Can't lock pub screen!");
78 /***********************************************************************************/
80 static struct Region
*shapefunc(struct Hook
*hook
, struct Layer
*lay
, struct ShapeHookMsg
*msg
)
82 struct Region
*newshape
, *retregion
= msg
->ActualShape
;
87 case SHAPEHOOKACTION_CREATELAYER
:
88 case SHAPEHOOKACTION_SIZELAYER
:
89 case SHAPEHOOKACTION_MOVESIZELAYER
:
90 x2
= msg
->NewBounds
.MaxX
- msg
->NewBounds
.MinX
;
91 y2
= msg
->NewBounds
.MaxY
- msg
->NewBounds
.MinY
;
93 if ((newshape
= NewRegion()))
95 struct Rectangle rect
;
102 success
&= OrRectRegion(newshape
, &rect
);
108 success
&= OrRectRegion(newshape
, &rect
);
114 success
&= OrRectRegion(newshape
, &rect
);
120 success
&= OrRectRegion(newshape
, &rect
);
126 success
&= OrRectRegion(newshape
, &rect
);
132 success
&= OrRectRegion(newshape
, &rect
);
138 success
&= OrRectRegion(newshape
, &rect
);
142 if (msg
->ActualShape
) DisposeRegion(msg
->ActualShape
);
143 retregion
= shape
= newshape
;
147 DisposeRegion(newshape
);
150 } /* if ((newshape = NewRegion())) */
152 } /* switch(msg->Action) */
157 /***********************************************************************************/
159 static void makewin(void)
161 shapehook
.h_Entry
= HookEntry
;
162 shapehook
.h_SubEntry
= (HOOKFUNC
)shapefunc
;
165 win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
)scr
,
166 WA_InnerWidth
, WINWIDTH
,
167 WA_InnerHeight
, WINHEIGHT
,
168 WA_Title
, (IPTR
)"Round Edged Window",
170 //WA_DepthGadget , TRUE,
171 //WA_CloseGadget , TRUE,
177 WA_SizeGadget
, TRUE
,
178 WA_SizeBBottom
, TRUE
,
179 WA_NoCareRefresh
, TRUE
,
180 WA_ShapeHook
, (IPTR
)&shapehook
,
181 WA_IDCMP
, IDCMP_CLOSEWINDOW
|
186 if (!win
) cleanup("Can't open window");
192 /***********************************************************************************/
196 /***********************************************************************************/
198 static void action(void)
200 struct IntuiMessage
*msg
;
204 WaitPort(win
->UserPort
);
206 while ((msg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
210 case IDCMP_CLOSEWINDOW
:
216 WORD code
= msg
->Code
& ~IECODE_UP_PREFIX
;
218 Keys
[code
] = (code
== msg
->Code
) ? 1 : 0;
225 ReplyMsg((struct Message
*)msg
);
228 } while(!Keys
[KC_ESC
]);
231 /***********************************************************************************/
244 /***********************************************************************************/