1 #include <intuition/intuition.h>
2 #include <graphics/gfx.h>
3 #include <graphics/gfxmacros.h>
4 #include <proto/exec.h>
5 #include <proto/intuition.h>
6 #include <proto/graphics.h>
7 #include <proto/alib.h>
14 #define WINCX (WINWIDTH / 2)
15 #define WINCY (WINHEIGHT / 2)
17 #define PATTERNWIDTH 32
18 #define PATTERNHEIGHT 32
19 #define PATTERNCOL1 SHADOWPEN
20 #define PATTERNCOL2 SHINEPEN
25 struct Rectangle bounds
;
30 struct IntuitionBase
*IntuitionBase
;
31 struct GfxBase
*GfxBase
;
34 struct Window
*win
, *win2
, *win3
;
36 struct BitMap
*patternbm
;
37 struct Hook backfillhook
;
39 static void cleanup(char *msg
)
41 if(msg
) printf("childchild: %s\n", msg
);
43 if (win3
) CloseWindow(win3
);
44 if (win2
) CloseWindow(win2
);
45 if (win
) CloseWindow(win
);
47 if (patternbm
) FreeBitMap(patternbm
);
49 if (dri
) FreeScreenDrawInfo(scr
, dri
);
50 if (scr
) UnlockPubScreen(0, scr
);
52 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
53 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
58 static void openlibs(void)
60 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39)))
62 cleanup("Can't open intuition.library!");
65 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 39)))
67 cleanup("Can't open graphics.library!");
72 static void getvisual(void)
74 if (!(scr
= LockPubScreen(0))) cleanup("Can't lock pub screen!");
75 if (!(dri
= GetScreenDrawInfo(scr
))) cleanup("Can't get drawinfo!");
79 static void MyBackfillFunc(struct Hook
*hook
,struct RastPort
*rp
,
80 struct LayerHookMsg
*msg
)
84 WORD x1
,y1
,x2
,y2
,px
,py
,pw
,ph
;
91 x1
= msg
->bounds
.MinX
;
92 y1
= msg
->bounds
.MinY
;
93 x2
= msg
->bounds
.MaxX
;
94 y2
= msg
->bounds
.MaxY
;
96 px
= (x1
- lay
->bounds
.MinX
) % PATTERNWIDTH
;
98 pw
= PATTERNWIDTH
- px
;
102 y1
= msg
->bounds
.MinY
;
103 py
= (y1
- lay
->bounds
.MinY
) % PATTERNHEIGHT
;
105 ph
= PATTERNHEIGHT
- py
;
107 if (pw
> (x2
- x1
+ 1)) pw
= x2
- x1
+ 1;
111 if (ph
> (y2
- y1
+ 1)) ph
= y2
- y1
+ 1;
130 } while (y1
<= y2
); /* while(y1 < y2) */
137 } while (x1
<= x2
); /* while (x1 < x2) */
141 static void InitBackfillHook(void)
143 backfillhook
.h_Entry
= HookEntry
;
144 backfillhook
.h_SubEntry
= (HOOKFUNC
)MyBackfillFunc
;
148 static void MakePattern(void)
150 struct RastPort
*temprp
;
152 if (!(patternbm
= AllocBitMap(PATTERNWIDTH
* 2,
154 GetBitMapAttr(scr
->RastPort
.BitMap
,BMA_DEPTH
),
156 scr
->RastPort
.BitMap
)))
158 cleanup("Can't create pattern bitmap!");
161 if (!(temprp
= CreateRastPort()))
163 cleanup("Can't create rastport!");
166 temprp
->BitMap
= patternbm
;
168 SetAPen(temprp
,dri
->dri_Pens
[PATTERNCOL1
]);
170 RectFill(temprp
,0,0,10,10);
172 RectFill(temprp
,0,0,PATTERNWIDTH
- 1,PATTERNHEIGHT
- 1);
174 SetAPen(temprp
,dri
->dri_Pens
[PATTERNCOL2
]);
177 PATTERNWIDTH
/ 2 - 1,
178 PATTERNHEIGHT
/ 2 - 1);
180 RectFill(temprp
,PATTERNWIDTH
/ 2,
185 FreeRastPort(temprp
);
188 static void makewin(void)
190 win
= OpenWindowTags(0, WA_PubScreen
, (IPTR
)scr
,
194 WA_Height
, WINHEIGHT
,
195 WA_Title
, (IPTR
)"Parent",
196 WA_CloseGadget
, TRUE
,
198 WA_DepthGadget
, TRUE
,
199 WA_IDCMP
, IDCMP_CLOSEWINDOW
,
201 WA_SimpleRefresh
, TRUE
,
202 WA_NoCareRefresh
,TRUE
,
203 WA_BackFill
, (IPTR
)&backfillhook
,
212 if (!win
) cleanup("Can't create parent window!");
214 win2
= OpenWindowTags(0, WA_PubScreen
, (IPTR
)scr
,
215 WA_Parent
, (IPTR
)win
,
218 WA_Width
, WINWIDTH
* 2 / 3,
219 WA_Height
, WINHEIGHT
* 2 / 3,
220 WA_Title
, (IPTR
)"Child",
222 WA_DepthGadget
, TRUE
,
223 WA_SimpleRefresh
, TRUE
,
224 WA_NoCareRefresh
,TRUE
,
233 if (!win2
) cleanup("Can't create child window!");
235 win3
= OpenWindowTags(0, WA_PubScreen
, (IPTR
)scr
,
236 WA_Parent
, (IPTR
)win2
,
239 WA_Width
, WINWIDTH
/ 2,
240 WA_Height
, WINHEIGHT
/ 2,
241 WA_Title
, (IPTR
)"Grand Child",
243 WA_DepthGadget
, TRUE
,
244 WA_SimpleRefresh
, TRUE
,
245 WA_NoCareRefresh
,TRUE
,
251 WA_NoCareRefresh
,TRUE
,
255 if (!win3
) cleanup("Can't create grand child window!");
259 static void handleall(void)
261 WaitPort(win
->UserPort
);