Fixed compatibility of output.
[AROS.git] / test / hidds / graphics / obsolete / GCNewDispose.c
blob74d66a469fa702cee76d39b78ea70b4b373355e5
1 /*
2 Copyright © 1998, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Test for graphics.hidd
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME
13 GCNewDispose
15 SYNOPSIS
17 GCNewDispose HIDD/K,FG/N/K,BG/N/K
19 LOCATION
21 test/HiddGraphics
23 FUNCTION
25 Creates a gc, prints the attributes of the gc and dispose
26 the gc
28 INPUTS
29 HIDD - name of the hidd to use e.g. "graphics-X11.hidd"
30 (default: graphics.hdd)
31 FG - Set foreground color to this value (default: 1)
32 BG - Set background color to this value (default: 2)
34 RESULT
35 RETURN_OK - hidd works
36 RETURN_ERROR - hidd produce errors
37 RETURN_FAIL - could not test hidd i.e. OpenLibrary() fails
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
47 INTERNALS
49 HISTORY
51 ******************************************************************************/
53 #define AROS_USE_OOP
55 #include <stdlib.h>
56 #include <stdio.h>
58 #include <aros/config.h>
60 #include <exec/types.h>
62 #include <proto/exec.h>
63 #include <proto/dos.h>
64 #include <proto/oop.h>
65 #include <proto/utility.h>
67 #include <utility/tagitem.h>
69 #include <oop/oop.h>
70 #include <hidd/graphics.h>
72 #include "gfxhiddtool.h"
74 #undef SDEBUG
75 #undef DEBUG
76 #define DEBUG 1
77 #include <aros/debug.h>
79 struct DosLibrary *DOSBase;
80 struct Library *OOPBase;
81 struct Library *HIDDGraphicsBase;
83 struct ght_OpenLibs LibsArray[] =
85 GHT_LIB("dos.library" , 37, &DOSBase),
86 GHT_LIB(AROSOOP_NAME , 0, &OOPBase),
87 GHT_LIB(NULL , 0, NULL)
89 /***************************************************************/
91 int main(int argc, char **argv)
93 ULONG ret = RETURN_FAIL;
95 OOP_AttrBase HiddGfxAttrBase = 0;
96 OOP_AttrBase HiddGCAttrBase = 0;
97 OOP_AttrBase HiddBitMapAttrBase = 0;
99 OOP_Object *gfxHidd;
100 OOP_Object *bitMap;
101 OOP_Object *gc;
103 STRPTR hiddName = "graphics.hidd";
104 ULONG fg = 1;
105 ULONG bg = 2;
107 /* ReadArgs() declarations */
108 /* each entry must have a size of 4 bytes */
109 struct Args
111 STRPTR hiddName;
112 IPTR *fg;
113 IPTR *bg;
116 struct Args args = {hiddName, &fg, &bg};
117 struct RDArgs *rda;
120 if(ght_OpenLibs(LibsArray))
122 rda = ReadArgs("HIDD/K,FG/N/K,BG/N/K", (IPTR *)&args, NULL);
123 if (rda != NULL)
125 HIDDGraphicsBase = OpenLibrary(args.hiddName, 0);
126 if(HIDDGraphicsBase)
128 ret = RETURN_ERROR;
130 HiddGfxAttrBase = OOP_ObtainAttrBase(IID_Hidd_Gfx);
131 HiddBitMapAttrBase = OOP_ObtainAttrBase(IID_Hidd_BitMap);
132 HiddGCAttrBase = OOP_ObtainAttrBase(IID_Hidd_GC);
133 if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase)
135 gfxHidd = OOP_NewObject(NULL, args.hiddName, NULL);
136 if(gfxHidd)
138 bitMap = HIDD_Gfx_NewBitMap(gfxHidd, NULL);
139 if(bitMap)
141 struct TagItem gc_tags[] =
143 {aHidd_GC_BitMap, (IPTR) bitMap},
144 {aHidd_GC_Foreground, (IPTR) *args.fg},
145 {aHidd_GC_Background, (IPTR) *args.bg},
146 {TAG_DONE, 0UL}
149 gc = HIDD_Gfx_NewGC(gfxHidd, gc_tags);
150 if(gc)
152 printf("GC created:\n");
153 printf(" fg : %li\n", ght_GetAttr(gc, aHidd_GC_Foreground));
154 printf(" bg : %li\n", ght_GetAttr(gc, aHidd_GC_Background));
155 printf(" drMode: %li\n", ght_GetAttr(gc, aHidd_GC_DrawMode));
156 printf(" bitMap: %li\n", ght_GetAttr(gc, aHidd_GC_BitMap));
158 HIDD_Gfx_DisposeGC(gfxHidd, gc);
160 ret = RETURN_OK;
163 HIDD_Gfx_DisposeBitMap(gfxHidd, bitMap);
166 if(gfxHidd) OOP_DisposeObject(gfxHidd);
167 } /* if(gfxHidd) */
168 } /* if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase) */
170 if(HiddGCAttrBase) OOP_ReleaseAttrBase(IID_Hidd_GC);
171 if(HiddBitMapAttrBase) OOP_ReleaseAttrBase(IID_Hidd_BitMap);
172 if(HiddGfxAttrBase) OOP_ReleaseAttrBase(IID_Hidd_Gfx);
174 CloseLibrary(HIDDGraphicsBase);
175 } /* if(HIDDGraphicsBase) */
177 FreeArgs(rda);
179 else
181 PrintFault(IoErr(), "");
182 } /* if (rda != NULL) */
184 } /* if OpenLibs() */
186 ght_CloseLibs(LibsArray);
188 return(ret);