home *** CD-ROM | disk | FTP | other *** search
- /*************************************
- * *
- * Gadgets v2.0 *
- * by Torsten Jürgeleit in 05/91 *
- * *
- * Test program *
- * *
- *************************************/
-
- /* Includes */
-
- #include <exec/types.h>
- #include <graphics/gfxbase.h>
- #include <graphics/text.h>
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <functions.h>
- #include <string.h>
- #include "render.h"
-
- /* Defines */
-
- #define WINDOW_WIDTH 600
- #define WINDOW_HEIGHT 200
- #define WINDOW_TITLE (UBYTE *)" Render test "
-
- #define RENDER_INFO_FLAGS (USHORT)(RENDER_INFO_FLAG_INNER_WINDOW | RENDER_INFO_FLAG_BACK_FILL)
- #define OPEN_WINDOW_FLAGS (USHORT)(OPEN_WINDOW_FLAG_CENTER_WINDOW | OPEN_WINDOW_FLAG_RENDER_PENS)
-
- /* Globals */
-
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
-
- /* Statics */
-
- STATIC struct NewWindow test_new_window = { 0, 0, WINDOW_WIDTH,
- WINDOW_HEIGHT, 0, 1, CLOSEWINDOW, WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH |
- SMART_REFRESH | NOCAREREFRESH | RMBTRAP | ACTIVATE, NULL, NULL,
- WINDOW_TITLE, NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN };
- STATIC struct TextAttr topaz60_attr = { (STRPTR)"topaz.font", TOPAZ_SIXTY,
- FS_NORMAL, FPF_ROMFONT };
- STATIC struct IntuiText itexts[] = {
- {
- 0, 0, JAM1, (WINDOW_WIDTH - 10 * 10) / 2, (WINDOW_HEIGHT - 6 * 8) / 2,
- &topaz60_attr, (UBYTE *)"Text pen 1", &itexts[1]
- }, {
- 0, 0, JAM1, (WINDOW_WIDTH - 10 * 10) / 2, (WINDOW_HEIGHT + 4 * 8) / 2,
- &topaz60_attr, (UBYTE *)"Text pen 2", NULL
- }
- };
- /* Prototypes */
-
- VOID test_action(struct RenderInfo *ri, struct Window *win);
-
- /* Pragmas */
-
- #pragma regcall(test_action(a0,a1))
-
- /* Render test */
-
- LONG
- main(VOID)
- {
- struct RenderInfo *ri;
- struct Window *win;
-
- if (IntuitionBase = OpenLibrary("intuition.library", 0L)) {
- if (GfxBase = OpenLibrary("graphics.library", 0L)) {
- if (ri = get_render_info(NULL, RENDER_INFO_FLAGS)) {
- if (win = open_window(ri, &test_new_window, OPEN_WINDOW_FLAGS)) {
- test_action(ri, win);
- CloseWindow(win);
- }
- free_render_info(ri);
- }
- CloseLibrary(GfxBase);
- }
- CloseLibrary(IntuitionBase);
- }
- return(0L);
- }
- /* Perform IDCMP action */
-
- VOID
- test_action(struct RenderInfo *ri, struct Window *win)
- {
- struct RastPort *rp = win->RPort;
- struct MsgPort *up = win->UserPort;
- struct Image *image = &ri->ri_Images[0];
- struct IntuiMessage *msg;
- ULONG left_edge = 40;
- USHORT i;
- BOOL keepon = TRUE;
-
- /* Init and print intui texts */
- itexts[0].FrontPen = ri->ri_TextPen1;
- itexts[1].FrontPen = ri->ri_TextPen2;
- PrintIText(rp, &itexts[0], 0L, 0L);
-
- /* Print render images */
- for (i = 0; i < MAX_RENDER_IMAGES; i++, image++, left_edge += 50) {
- DrawImage(rp, image, left_edge, (LONG)((WINDOW_HEIGHT -
- (2 * image->TopEdge + image->Height)) / 2));
- }
-
- /* Waiting for close window event */
- do {
- WaitPort(up);
- while (msg = (struct IntuiMessage *)GetMsg(up)) {
- if (msg->Class == CLOSEWINDOW) {
- keepon = FALSE;
- }
- ReplyMsg((struct Message *)msg);
- }
- } while (keepon == TRUE);
- }
-