2 Copyright © 1998, The AROS Development Team. All rights reserved.
5 Desc: Demo showing x11gfx.hidd
11 #include <exec/types.h>
12 #include <graphics/rastport.h>
13 #include <graphics/gfxmacros.h>
14 #include <intuition/intuition.h>
15 #include <proto/dos.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/intuition.h>
23 #include <aros/debug.h>
26 #define WIN_HEIGHT 300
28 struct IntuitionBase
*IntuitionBase
;
29 struct GfxBase
*GfxBase
;
30 struct Library
*LayersBase
;
31 struct DosLibrary
*DOSBase
;
33 struct Window
*openwindow(STRPTR title
, LONG x
, LONG y
, LONG w
, LONG h
);
35 void test_text(struct Window
*w
);
37 int handleevents(struct Window
*win
);
39 enum { EV_KEY_PRESSED
, EV_QUIT
};
41 int main(int argc
, char **argv
)
43 /* Intialize debugging */
46 if ((IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 0)))
48 if ((GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 0)))
50 if ((DOSBase
= (struct DosLibrary
*) OpenLibrary("dos.library",0)))
55 w1
= openwindow("Text speed test. Press key to show JAM1"
57 , WIN_WIDTH
, WIN_HEIGHT
62 struct TextAttr ta
= { "topaz.font", 8, 0, 0 };
65 /* Get the default font */
70 SetFont(w1
->RPort
, tf
);
72 if (handleevents(w1
) == EV_QUIT
)
75 SetDrMd(w1
->RPort
, JAM1
);
78 SetWindowTitles(w1
, "Press any key to test JAM2", NULL
);
81 if (handleevents(w1
) == EV_QUIT
)
84 SetDrMd(w1
->RPort
, JAM2
);
85 SetAPen(w1
->RPort
, DETAILPEN
);
86 SetBPen(w1
->RPort
, BLOCKPEN
);
89 SetWindowTitles(w1
, "Press a key to quit", NULL
);
98 CloseLibrary((struct Library
*)DOSBase
);
100 CloseLibrary((struct Library
*)GfxBase
);
102 CloseLibrary((struct Library
*) IntuitionBase
);
107 #define TEST_TEXT "Blah"
109 void test_text(struct Window
*w
)
111 int len
, pixlen
, pixleft
, iw
;
117 bottom
= WIN_HEIGHT
- w
->BorderBottom
- 1 - (tf
->tf_YSize
- tf
->tf_Baseline
);
118 printf("bottom: %d\n", bottom
);
119 y
= w
->BorderTop
+ tf
->tf_Baseline
;
121 iw
= w
->Width
- w
->BorderLeft
- w
->BorderRight
;
123 len
= sizeof (TEST_TEXT
) - 1;
125 pixlen
= TextLength(w
->RPort
, TEST_TEXT
, len
);
127 for (; y
< bottom
; y
+= tf
->tf_YSize
)
134 Move(w
->RPort
, x
, y
);
135 Text(w
->RPort
, TEST_TEXT
, len
);
138 while (pixleft
> pixlen
);
144 struct Window
*openwindow(STRPTR title
, LONG x
, LONG y
, LONG w
, LONG h
)
147 struct Window
*window
;
149 window
= OpenWindowTags(NULL
,
150 WA_IDCMP
, IDCMP_RAWKEY
,
156 WA_DepthGadget
, TRUE
,
157 WA_CloseGadget
, TRUE
,
158 WA_Title
, (IPTR
)title
,
166 int handleevents(struct Window
*win
)
168 struct IntuiMessage
*imsg
;
169 struct MsgPort
*port
= win
->UserPort
;
173 EnterFunc(bug("HandleEvents(win=%p)\n", win
));
177 if ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
184 case IDCMP_REFRESHWINDOW
:
186 EndRefresh(win
, TRUE
);
189 case IDCMP_CLOSEWINDOW
:
195 if (imsg
->Code
& 0x80)
198 event
= EV_KEY_PRESSED
;
204 } /* switch (imsg->Class) */
205 ReplyMsg((struct Message
*)imsg
);
208 } /* if ((imsg = GetMsg(port)) != NULL) */
211 Wait(1L << port
->mp_SigBit
);
213 } /* while (!terminated) */
215 ReturnInt("HandleEvents", int, event
);
216 } /* HandleEvents() */