2 #include <intuition/intuition.h>
3 #include <graphics/gfx.h>
4 #include <graphics/gfxmacros.h>
5 #include <utility/tagitem.h>
6 #include <proto/exec.h>
7 #include <proto/intuition.h>
8 #include <proto/graphics.h>
9 #include <proto/layers.h>
10 #include <aros/debug.h>
17 #define WINCX (WINWIDTH / 2)
18 #define WINCY (WINHEIGHT / 2)
20 struct IntuitionBase
*IntuitionBase
;
21 struct GfxBase
*GfxBase
;
22 struct Library
*LayersBase
;
31 static void cleanup(char *msg
)
33 if(msg
) printf("winshape: %s\n", msg
);
35 if (win
) CloseWindow(win
);
37 // if (shape) DisposeRegion(shape);
39 if (dri
) FreeScreenDrawInfo(scr
, dri
);
40 if (scr
) UnlockPubScreen(0, scr
);
42 if (LayersBase
) CloseLibrary(LayersBase
);
43 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
44 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
50 static void openlibs(void)
52 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
54 cleanup("Can't open intuition.library!");
57 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
59 cleanup("Can't open graphics.library!");
62 if (!(LayersBase
= OpenLibrary("layers.library", 39)))
64 cleanup("Can't open layers.library!");
70 static void getvisual(void)
72 if (!(scr
= LockPubScreen(0))) cleanup("Can't lock pub screen!");
73 if (!(dri
= GetScreenDrawInfo(scr
))) cleanup("Can't get drawinfo!");
77 static void makeshape(void)
79 struct Rectangle rect
;
82 if (!(shape
= NewRectRegion(0, 0, WINWIDTH
- 1, scr
->WBorTop
+ scr
->Font
->ta_YSize
+ 1 - 1)))
83 cleanup("Can't create region!\n");
85 if (!(shape
= NewRegion())) cleanup("Can't create region!\n");
89 rect
.MaxX
= WINWIDTH
- 1;
90 rect
.MaxY
= scr
->WBorTop
+ scr
->Font
->ta_YSize
+ 1 - 1;
92 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n");
95 rect
.MinX
= WINCX
- 20;
97 rect
.MaxX
= WINCX
+ 20;
98 rect
.MaxY
= WINHEIGHT
- 1 - 20;
100 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n");
103 rect
.MinY
= WINCY
- 20;
104 rect
.MaxX
= WINWIDTH
- 1 - 20;
105 rect
.MaxY
= WINCY
+ 20;
107 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n");
112 static void makewin(void)
114 UWORD pattern
[] = {0x5555, 0xAAAA};
115 struct TagItem win_tags
[] =
119 { WA_Width
, WINWIDTH
},
120 { WA_Height
, WINHEIGHT
},
121 { WA_Title
, (IPTR
)"Irregular shaped window" },
122 { WA_CloseGadget
, TRUE
},
123 { WA_DepthGadget
, TRUE
},
124 { WA_DragBar
, TRUE
},
125 { WA_IDCMP
, IDCMP_CLOSEWINDOW
| IDCMP_VANILLAKEY
},
126 { WA_Activate
, TRUE
},
127 { WA_Shape
, (IPTR
)shape
},
131 win
= OpenWindowTagList(0, win_tags
);
132 if (!win
) cleanup("Can't create window!");
135 SetAPen(rp
, dri
->dri_Pens
[FILLPEN
]);
136 SetBPen(rp
, dri
->dri_Pens
[SHINEPEN
]);
139 SetAfPt(rp
, pattern
, 1);
140 RectFill(rp
, win
->BorderLeft
,
142 WINWIDTH
- 1 - win
->BorderRight
,
143 WINHEIGHT
- 1 - win
->BorderBottom
);
146 SetAPen(rp
, dri
->dri_Pens
[SHINEPEN
]);
147 RectFill(rp
, WINCX
- 20, 20, WINCX
+ 20, 20);
148 RectFill(rp
, WINCX
- 20, 21, WINCX
- 20, WINCY
- 20);
149 RectFill(rp
, 20, WINCY
- 20, WINCX
- 20, WINCY
- 20);
150 RectFill(rp
, 20, WINCY
- 20, 20, WINCY
+ 20);
151 RectFill(rp
, WINCX
- 20, WINCY
+ 20, WINCX
- 20, WINHEIGHT
- 1 - 20);
152 RectFill(rp
, WINCX
+ 20, WINCY
- 20, WINWIDTH
- 1 - 20, WINCY
- 20);
154 SetAPen(rp
, dri
->dri_Pens
[SHADOWPEN
]);
155 RectFill(rp
, WINCX
+ 20, 20, WINCX
+ 20, WINCY
- 20);
156 RectFill(rp
, WINCX
+ 20, WINCY
+ 20, WINWIDTH
- 1 - 20, WINCY
+ 20);
157 RectFill(rp
, WINWIDTH
- 1 - 20, WINCY
- 20, WINWIDTH
- 1 - 20, WINCY
+ 20);
158 RectFill(rp
, 20, WINCY
+ 20, WINCX
- 20, WINCY
+ 20);
159 RectFill(rp
, WINCX
- 20, WINHEIGHT
- 1 - 20, WINCX
+ 20, WINHEIGHT
- 1 - 20);
160 RectFill(rp
, WINCX
+ 20, WINCY
+ 20, WINCX
+ 20, WINHEIGHT
- 1 - 20);
163 static void handleall(void)
165 struct IntuiMessage
*imsg
;
168 struct TagItem taglist
[] = {
170 {LA_DESTHEIGHT
, 0 },
176 WaitPort(win
->UserPort
);
178 while ((imsg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
182 case IDCMP_CLOSEWINDOW
:
186 case IDCMP_VANILLAKEY
:
192 * '+': enlarge the layer.
194 taglist
[0].ti_Data
= (win
->Width
*3)/2;
195 taglist
[1].ti_Data
= (win
->Height
*3)/2;
196 ScaleLayer(win
->WLayer
, taglist
);
201 * '-': make layer smaller.
203 taglist
[0].ti_Data
= (win
->Width
*2)/3;
204 taglist
[1].ti_Data
= (win
->Height
*2)/3;
205 ScaleLayer(win
->WLayer
, taglist
);
209 actshape
= 1 - actshape
;
210 ChangeWindowShape(win
, (actshape
? NULL
: shape
), NULL
);
215 ReplyMsg((struct Message
*)imsg
);