Fixed compatibility of output.
[AROS.git] / test / hidds / graphics / obsolete / GCDrawText.c
blob135817280d68a774de73429f0ef1d9f373963148
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 GCDrawText
15 SYNOPSIS
17 GCDrawText HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S
19 LOCATION
21 test/HiddGraphics
23 FUNCTION
25 Creates a gc, draws some texts and disposes the gc.
27 INPUTS
28 HIDD - name of the hidd to use e.g. "graphics-X11.hidd"
29 (default: graphics.hidd)
30 WIDTH - width of bitmap (default: 320)
31 HEIGHT - height of bitmap (default: 200)
32 DEPTH - depth of bitmap (default: 8)
33 CHUNKY - create bitmap in chunky-mode (default: planar)
34 DISPLAYABLE - show bitmap (default: FALSE)
36 RESULT
37 RETURN_OK - hidd works
38 RETURN_ERROR - hidd produce errors
39 RETURN_FAIL - could not test hidd i.e. OpenLibrary() fails
41 NOTES
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 HISTORY
53 ******************************************************************************/
55 #define AROS_USE_OOP
57 #include <stdlib.h>
58 #include <stdio.h>
60 #include <aros/config.h>
62 #include <exec/types.h>
64 #include <proto/exec.h>
65 #include <proto/graphics.h>
66 #include <proto/diskfont.h>
67 #include <proto/dos.h>
68 #include <proto/oop.h>
69 #include <proto/utility.h>
71 #include <graphics/text.h>
72 #include <utility/tagitem.h>
74 #include <oop/oop.h>
75 #include <hidd/graphics.h>
76 #include <hidd/graphics-amiga-intuition.h>
78 #include "gfxhiddtool.h"
80 #undef SDEBUG
81 #undef DEBUG
82 #define DEBUG 1
83 #include <aros/debug.h>
85 struct DosLibrary *DOSBase;
86 struct Library *OOPBase;
87 struct Library *HIDDGraphicsBase;
88 struct Library *DiskfontBase;
89 struct GfxBase *GfxBase;
91 struct ght_OpenLibs LibsArray[] =
93 GHT_LIB("dos.library" , 37, &DOSBase),
94 GHT_LIB(AROSOOP_NAME , 0, &OOPBase),
95 GHT_LIB("diskfont.library" , 37, &DiskfontBase),
96 GHT_LIB("graphics.library" , 37, &GfxBase),
97 GHT_LIB(NULL , 0, NULL)
99 /***************************************************************/
101 int main(int argc, char **argv)
103 ULONG ret = RETURN_FAIL;
105 OOP_AttrBase HiddGCAttrBase;
106 OOP_AttrBase HiddGfxAttrBase;
107 OOP_AttrBase HiddBitMapAttrBase;
109 OOP_Object *gfxHidd;
110 OOP_Object *bitMap;
111 OOP_Object *gc;
113 STRPTR hiddName = "graphics.hidd";
114 ULONG width = 320;
115 ULONG height = 200;
116 ULONG depth = 8;
117 ULONG format = vHidd_BitMap_Format_Planar;
118 char wait;
120 struct TextFont *font;
121 struct TextAttr attr = {"ruby.font", 12, 0, 0};
123 struct Args
125 STRPTR hiddName;
126 IPTR *width;
127 IPTR *height;
128 IPTR *depth;
129 IPTR *chunky;
130 ULONG displayable;
133 struct Args args = {hiddName, &width, &height, &depth, 0, 0};
134 struct RDArgs *rda;
137 if(ght_OpenLibs(LibsArray))
139 rda = ReadArgs("HIDD/K,WIDTH/N/K,HEIGHT/N/K,DEPTH/N/K,CHUNKY/S,DISPLAYABLE=DP/S", (IPTR *)&args, NULL);
140 if (rda != NULL)
142 if(args.chunky != 0) format = vHidd_BitMap_Format_Chunky;
143 if(args.displayable != 0) args.displayable = (ULONG) TRUE;
145 HIDDGraphicsBase = OpenLibrary(args.hiddName, 0);
146 if(HIDDGraphicsBase)
148 ret = RETURN_ERROR;
150 HiddGfxAttrBase = OOP_ObtainAttrBase(IID_Hidd_Gfx);
151 HiddBitMapAttrBase = OOP_ObtainAttrBase(IID_Hidd_BitMap);
152 HiddGCAttrBase = OOP_ObtainAttrBase(IID_Hidd_GC);
154 if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase)
156 gfxHidd = OOP_NewObject(NULL, args.hiddName, NULL);
157 if(gfxHidd)
159 struct TagItem bm_tags[] =
161 {aHidd_BitMap_Width, (IPTR) *args.width},
162 {aHidd_BitMap_Height, (IPTR) *args.height},
163 {aHidd_BitMap_Depth, (IPTR) *args.depth},
164 {aHidd_BitMap_Format, (IPTR) format},
165 {aHidd_BitMap_Displayable, (IPTR) args.displayable},
166 {TAG_DONE, 0UL}
169 bitMap = HIDD_Gfx_NewBitMap(gfxHidd, bm_tags);
170 if(bitMap)
172 struct TagItem gc_tags[] =
174 {aHidd_GC_BitMap, (IPTR) bitMap},
175 {TAG_DONE, 0UL}
178 gc = HIDD_Gfx_NewGC(gfxHidd, gc_tags);
179 if(gc)
181 font = OpenDiskFont(&attr);
182 if(font)
184 OOP_SetAttrsTags(gc, aHidd_GC_Font, (IPTR) font, TAG_END);
185 HIDD_BM_DrawText(gc, 10, 30, "AROS - The AROS Research OS", 28);
187 printf("Press enter to continue");
188 scanf("%c", &wait);
190 CloseFont(font);
193 ret = RETURN_OK;
196 HIDD_Gfx_DisposeBitMap(gfxHidd, bitMap);
199 if(gfxHidd) OOP_DisposeObject(gfxHidd);
201 } /* if(HiddGfxAttrBase && HiddBitMapAttrBase && HiddGCAttrBase) */
203 if(HiddGfxAttrBase) OOP_ReleaseAttrBase(IID_Hidd_Gfx);
204 if(HiddBitMapAttrBase) OOP_ReleaseAttrBase(IID_Hidd_BitMap);
205 if(HiddGCAttrBase) OOP_ReleaseAttrBase(IID_Hidd_GC);
207 CloseLibrary(HIDDGraphicsBase);
208 } /* if(HIDDGraphicsBase) */
209 FreeArgs(rda);
211 else
213 PrintFault(IoErr(), "");
214 } /* if (rda != NULL) */
215 } /* if OpenLibs() */
217 ght_CloseLibs(LibsArray);
219 return(ret);