2 #include <intuition/intuition.h>
3 #include <graphics/gfx.h>
4 #include <graphics/gfxmacros.h>
5 #include <utility/tagitem.h>
6 #include <proto/alib.h>
7 #include <proto/exec.h>
8 #include <proto/intuition.h>
9 #include <proto/graphics.h>
10 #include <proto/layers.h>
11 #include <aros/debug.h>
18 #define WINCX (WINWIDTH / 2)
19 #define WINCY (WINHEIGHT / 2)
21 struct IntuitionBase
*IntuitionBase
;
22 struct GfxBase
*GfxBase
;
23 struct Library
*LayersBase
;
32 static void cleanup(char *msg
)
34 if(msg
) printf("winshape: %s\n", msg
);
36 if (win
) CloseWindow(win
);
38 // if (shape) DisposeRegion(shape);
40 if (dri
) FreeScreenDrawInfo(scr
, dri
);
41 if (scr
) UnlockPubScreen(0, scr
);
43 if (LayersBase
) CloseLibrary(LayersBase
);
44 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
45 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
51 static void openlibs(void)
53 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
55 cleanup("Can't open intuition.library!");
58 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
60 cleanup("Can't open graphics.library!");
63 if (!(LayersBase
= OpenLibrary("layers.library", 39)))
65 cleanup("Can't open layers.library!");
71 static void getvisual(void)
73 if (!(scr
= LockPubScreen(0))) cleanup("Can't lock pub screen!");
74 if (!(dri
= GetScreenDrawInfo(scr
))) cleanup("Can't get drawinfo!");
78 static void makeshape(void)
80 struct Rectangle rect
;
83 if (!(shape
= NewRectRegion(0, 0, WINWIDTH
- 1, scr
->WBorTop
+ scr
->Font
->ta_YSize
+ 1 - 1)))
84 cleanup("Can't create region!\n");
86 if (!(shape
= NewRegion())) cleanup("Can't create region!\n");
90 rect
.MaxX
= WINWIDTH
- 1;
91 rect
.MaxY
= scr
->WBorTop
+ scr
->Font
->ta_YSize
+ 1 - 1;
93 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n");
96 rect
.MinX
= WINCX
- 20;
98 rect
.MaxX
= WINCX
+ 20;
99 rect
.MaxY
= WINHEIGHT
- 1 - 20;
101 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n");
104 rect
.MinY
= WINCY
- 20;
105 rect
.MaxX
= WINWIDTH
- 1 - 20;
106 rect
.MaxY
= WINCY
+ 20;
108 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n");
113 static void makewin(void)
115 UWORD pattern
[] = {0x5555, 0xAAAA};
116 struct TagItem win_tags
[] =
120 { WA_Width
, WINWIDTH
},
121 { WA_Height
, WINHEIGHT
},
122 { WA_Title
, (IPTR
)"Irregular shaped window" },
123 { WA_CloseGadget
, TRUE
},
124 { WA_DepthGadget
, TRUE
},
125 { WA_DragBar
, TRUE
},
126 { WA_IDCMP
, IDCMP_CLOSEWINDOW
| IDCMP_VANILLAKEY
},
127 { WA_Activate
, TRUE
},
128 { WA_ShapeRegion
, (IPTR
)shape
},
132 win
= OpenWindowTagList(0, win_tags
);
133 if (!win
) cleanup("Can't create window!");
136 SetAPen(rp
, dri
->dri_Pens
[FILLPEN
]);
137 SetBPen(rp
, dri
->dri_Pens
[SHINEPEN
]);
140 SetAfPt(rp
, pattern
, 1);
141 RectFill(rp
, win
->BorderLeft
,
143 WINWIDTH
- 1 - win
->BorderRight
,
144 WINHEIGHT
- 1 - win
->BorderBottom
);
147 SetAPen(rp
, dri
->dri_Pens
[SHINEPEN
]);
148 RectFill(rp
, WINCX
- 20, 20, WINCX
+ 20, 20);
149 RectFill(rp
, WINCX
- 20, 21, WINCX
- 20, WINCY
- 20);
150 RectFill(rp
, 20, WINCY
- 20, WINCX
- 20, WINCY
- 20);
151 RectFill(rp
, 20, WINCY
- 20, 20, WINCY
+ 20);
152 RectFill(rp
, WINCX
- 20, WINCY
+ 20, WINCX
- 20, WINHEIGHT
- 1 - 20);
153 RectFill(rp
, WINCX
+ 20, WINCY
- 20, WINWIDTH
- 1 - 20, WINCY
- 20);
155 SetAPen(rp
, dri
->dri_Pens
[SHADOWPEN
]);
156 RectFill(rp
, WINCX
+ 20, 20, WINCX
+ 20, WINCY
- 20);
157 RectFill(rp
, WINCX
+ 20, WINCY
+ 20, WINWIDTH
- 1 - 20, WINCY
+ 20);
158 RectFill(rp
, WINWIDTH
- 1 - 20, WINCY
- 20, WINWIDTH
- 1 - 20, WINCY
+ 20);
159 RectFill(rp
, 20, WINCY
+ 20, WINCX
- 20, WINCY
+ 20);
160 RectFill(rp
, WINCX
- 20, WINHEIGHT
- 1 - 20, WINCX
+ 20, WINHEIGHT
- 1 - 20);
161 RectFill(rp
, WINCX
+ 20, WINCY
+ 20, WINCX
+ 20, WINHEIGHT
- 1 - 20);
164 static void handleall(void)
166 struct IntuiMessage
*imsg
;
169 struct TagItem taglist
[] = {
171 {LA_DESTHEIGHT
, 0 },
177 WaitPort(win
->UserPort
);
179 while ((imsg
= (struct IntuiMessage
*)GetMsg(win
->UserPort
)))
183 case IDCMP_CLOSEWINDOW
:
187 case IDCMP_VANILLAKEY
:
193 * '+': enlarge the layer.
195 taglist
[0].ti_Data
= (win
->Width
*3)/2;
196 taglist
[1].ti_Data
= (win
->Height
*3)/2;
197 ScaleLayer(win
->WLayer
, taglist
);
202 * '-': make layer smaller.
204 taglist
[0].ti_Data
= (win
->Width
*2)/3;
205 taglist
[1].ti_Data
= (win
->Height
*2)/3;
206 ScaleLayer(win
->WLayer
, taglist
);
210 actshape
= 1 - actshape
;
211 ChangeWindowShape(win
, (actshape
? NULL
: shape
), NULL
);
216 ReplyMsg((struct Message
*)imsg
);