2 #include <intuition/intuition.h>
3 #include <graphics/gfx.h>
4 #include <graphics/gfxmacros.h>
5 #include <proto/exec.h>
6 #include <proto/intuition.h>
7 #include <proto/graphics.h>
9 #include <dos/rdargs.h>
16 #define WINCX (WINWIDTH / 2)
17 #define WINCY (WINHEIGHT / 2)
19 struct IntuitionBase
*IntuitionBase
;
20 struct GfxBase
*GfxBase
;
27 static void cleanup(char *msg
, struct Window
*w
)
29 if(msg
) printf("winshape: %s\n", msg
);
31 if (w
) CloseWindow(w
);
33 if (shape
) DisposeRegion(shape
);
35 if (dri
) FreeScreenDrawInfo(scr
, dri
);
36 if (scr
) UnlockPubScreen(0, scr
);
38 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
39 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
44 static void openlibs(void)
46 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
48 cleanup("Can't open intuition.library!", NULL
);
51 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
53 cleanup("Can't open graphics.library!", NULL
);
58 static void getvisual(void)
60 if (!(scr
= LockPubScreen(0))) cleanup("Can't lock pub screen!", NULL
);
61 if (!(dri
= GetScreenDrawInfo(scr
))) cleanup("Can't get drawinfo!", NULL
);
64 static void makeshape(void)
66 struct Rectangle rect
;
68 if (!(shape
= NewRegion())) cleanup("Can't create region!\n", NULL
);
72 rect
.MaxX
= WINWIDTH
- 1;
73 rect
.MaxY
= scr
->WBorTop
+ scr
->Font
->ta_YSize
+ 1 - 1;
75 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n", NULL
);
77 rect
.MinX
= WINCX
- 20;
79 rect
.MaxX
= WINCX
+ 20;
80 rect
.MaxY
= WINHEIGHT
- 1 - 20;
82 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n", NULL
);
85 rect
.MinY
= WINCY
- 20;
86 rect
.MaxX
= WINWIDTH
- 1 - 20;
87 rect
.MaxY
= WINCY
+ 20;
89 if (!(OrRectRegion(shape
, &rect
))) cleanup("Can't create region!\n", NULL
);
93 static struct Window
* makeparentwin(ULONG visible
)
95 struct TagItem win_tags
[] =
101 { WA_MinWidth
, 200 },
102 { WA_MaxWidth
, 500 },
103 { WA_MinHeight
, 200 },
104 { WA_MaxHeight
, 400 },
105 { WA_Title
, (IPTR
)"Parent window" },
106 { WA_CloseGadget
, TRUE
},
107 { WA_DepthGadget
, TRUE
},
108 { WA_DragBar
, TRUE
},
109 { WA_IDCMP
, IDCMP_CLOSEWINDOW
},
110 { WA_Activate
, TRUE
},
111 { WA_Visible
, (IPTR
)visible
},
112 { WA_SizeGadget
, TRUE
},
116 return OpenWindowTagList(0, win_tags
);
119 static void makewin(struct Window
* parent
)
121 UWORD pattern
[] = {0x5555, 0xAAAA};
122 struct TagItem win_tags
[] =
126 { WA_Width
, WINWIDTH
},
127 { WA_Height
, WINHEIGHT
},
128 { WA_Title
, (IPTR
)"Irregular shaped window" },
129 { WA_DepthGadget
, TRUE
},
130 { WA_DragBar
, TRUE
},
131 { WA_Activate
, TRUE
},
132 { WA_Shape
, (IPTR
)shape
},
133 { WA_Parent
, (IPTR
)parent
},
137 win
= OpenWindowTagList(0, win_tags
);
139 if (!win
) cleanup("Can't create window!", NULL
);
142 SetAPen(rp
, dri
->dri_Pens
[FILLPEN
]);
143 SetBPen(rp
, dri
->dri_Pens
[SHINEPEN
]);
146 SetAfPt(rp
, pattern
, 1);
147 RectFill(rp
, 0, 20, WINWIDTH
- 1, WINHEIGHT
- 1);
150 SetAPen(rp
, dri
->dri_Pens
[SHINEPEN
]);
151 RectFill(rp
, WINCX
- 20, 20, WINCX
+ 20, 20);
152 RectFill(rp
, WINCX
- 20, 21, WINCX
- 20, WINCY
- 20);
153 RectFill(rp
, 20, WINCY
- 20, WINCX
- 20, WINCY
- 20);
154 RectFill(rp
, 20, WINCY
- 20, 20, WINCY
+ 20);
155 RectFill(rp
, WINCX
- 20, WINCY
+ 20, WINCX
- 20, WINHEIGHT
- 1 - 20);
156 RectFill(rp
, WINCX
+ 20, WINCY
- 20, WINWIDTH
- 1 - 20, WINCY
- 20);
158 SetAPen(rp
, dri
->dri_Pens
[SHADOWPEN
]);
159 RectFill(rp
, WINCX
+ 20, 20, WINCX
+ 20, WINCY
- 20);
160 RectFill(rp
, WINCX
+ 20, WINCY
+ 20, WINWIDTH
- 1 - 20, WINCY
+ 20);
161 RectFill(rp
, WINWIDTH
- 1 - 20, WINCY
- 20, WINWIDTH
- 1 - 20, WINCY
+ 20);
162 RectFill(rp
, 20, WINCY
+ 20, WINCX
- 20, WINCY
+ 20);
163 RectFill(rp
, WINCX
- 20, WINHEIGHT
- 1 - 20, WINCX
+ 20, WINHEIGHT
- 1 - 20);
164 RectFill(rp
, WINCX
+ 20, WINCY
+ 20, WINCX
+ 20, WINHEIGHT
- 1 - 20);
167 static void handleall(struct Window
* w
)
169 WaitPort(w
->UserPort
);
172 int main(int argc
, char **argv
)
174 STRPTR args
[1] = {(STRPTR
)FALSE
};
177 ULONG visible
= TRUE
;
179 rda
= ReadArgs("INVISIBLE/S", (IPTR
*)args
, NULL
);
181 if (TRUE
== (IPTR
)args
[0])
191 w
= makeparentwin(visible
);