2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Read an icon from an .info file
10 #include <aros/bigendianio.h>
11 #include <graphics/gfxbase.h>
12 #include <workbench/workbench.h>
13 #include <workbench/icon.h>
14 #include <devices/inputevent.h>
16 #include <proto/icon.h>
17 #include <proto/exec.h>
18 #include <proto/dos.h>
19 #include <proto/intuition.h>
21 static const char version
[] __attribute__((used
)) = "$VER: readicon 41.2 (5.9.1997)\n";
23 #define IM(x) ((struct Image *)x)
25 struct IntuitionBase
*IntuitionBase
;
26 struct GfxBase
*GfxBase
;
27 struct Library
* IconBase
;
29 void DoWindow (struct DiskObject
* dobj
)
31 struct Window
* win
= NULL
;
33 struct IntuiMessage
* im
;
36 GfxBase
=(struct GfxBase
*)OpenLibrary(GRAPHICSNAME
,39);
37 IntuitionBase
=(struct IntuitionBase
*)OpenLibrary("intuition.library",39);
41 printf ("Couldn't open %s\n", GRAPHICSNAME
);
47 printf ("Couldn't open intuition.library\n");
51 win
= OpenWindowTags (NULL
52 , WA_Title
, (IPTR
)"Show an icon"
54 , WA_CloseGadget
, TRUE
55 , WA_DepthGadget
, TRUE
59 , WA_InnerWidth
, dobj
->do_Gadget
.Width
* 3 + 40
60 , WA_InnerHeight
, dobj
->do_Gadget
.Height
+ 20
61 , WA_IDCMP
, IDCMP_RAWKEY
| IDCMP_CLOSEWINDOW
62 , WA_SimpleRefresh
, TRUE
71 dobj
->do_Gadget
.LeftEdge
= win
->BorderLeft
+ dobj
->do_Gadget
.Width
* 2 + 30;
72 dobj
->do_Gadget
.TopEdge
= win
->BorderTop
+ 10;
74 AddGadget(win
, &dobj
->do_Gadget
, -1);
75 RefreshGList(&dobj
->do_Gadget
, win
, NULL
, 1);
77 DrawImage (rp
, dobj
->do_Gadget
.GadgetRender
, win
->BorderLeft
+ 10, win
->BorderTop
+ 10);
78 DrawImage (rp
, dobj
->do_Gadget
.SelectRender
, win
->BorderLeft
+ 20 + dobj
->do_Gadget
.Width
, win
->BorderTop
+ 10);
82 printf ("Press a key to exit\n");
86 if ((im
= (struct IntuiMessage
*)GetMsg (win
->UserPort
)))
89 printf("Got msg %lx\n", (long)im
->Class
);
93 case IDCMP_CLOSEWINDOW
:
98 if (!(im
->Code
& IECODE_UP_PREFIX
))
106 ReplyMsg ((struct Message
*)im
);
110 /* D("Waiting\n"); */
111 Wait (1L << win
->UserPort
->mp_SigBit
);
120 CloseLibrary ((struct Library
*)GfxBase
);
123 CloseLibrary ((struct Library
*)IntuitionBase
);
128 int main (int argc
, char ** argv
)
131 struct DiskObject
* dobj
;
139 IconBase
= OpenLibrary (ICONNAME
, 39);
143 printf ("Couldn't open %s\n", ICONNAME
);
147 rda
= ReadArgs ("IconFile/A", (IPTR
*)&arg
, NULL
);
151 if (!(dobj
= GetDiskObject (arg
)) )
153 printf ("Cannot open icon for %s: ", arg
);
154 PrintFault (IoErr(), "");
159 /* hexdump (dobj, 0L, sizeof (struct DiskObject)); */
161 printf ("Some information about the icon:\n"
165 "Gadget: %dx%d+%d+%d Flags=%x Act=%x Type=%d\n"
170 , dobj
->do_Gadget
.Width
171 , dobj
->do_Gadget
.Height
172 , dobj
->do_Gadget
.LeftEdge
173 , dobj
->do_Gadget
.TopEdge
174 , dobj
->do_Gadget
.Flags
175 , dobj
->do_Gadget
.Activation
176 , dobj
->do_Gadget
.GadgetType
177 , (long)dobj
->do_StackSize
180 if (dobj
->do_Gadget
.GadgetRender
)
182 printf ("GImage: %dx%d+%d+%d\n"
183 , IM(dobj
->do_Gadget
.GadgetRender
)->Width
184 , IM(dobj
->do_Gadget
.GadgetRender
)->Height
185 , IM(dobj
->do_Gadget
.GadgetRender
)->LeftEdge
186 , IM(dobj
->do_Gadget
.GadgetRender
)->TopEdge
189 /* hexdump (IM(dobj->do_Gadget.GadgetRender)->ImageData
196 printf ("GImage: none\n");
199 if (dobj
->do_Gadget
.SelectRender
)
201 printf ("SImage: %dx%d+%d+%d\n"
202 , IM(dobj
->do_Gadget
.SelectRender
)->Width
203 , IM(dobj
->do_Gadget
.SelectRender
)->Height
204 , IM(dobj
->do_Gadget
.SelectRender
)->LeftEdge
205 , IM(dobj
->do_Gadget
.SelectRender
)->TopEdge
208 /* hexdump (IM(dobj->do_Gadget.SelectRender)->ImageData
215 printf ("SImage: none\n");
218 printf ("DefaultTool: %s\n", dobj
->do_DefaultTool
);
220 printf ("ToolTypes:\n");
222 if (dobj
->do_ToolTypes
)
223 for (t
=0; dobj
->do_ToolTypes
[t
]; t
++)
224 printf ("TT %d: %s\n", t
, dobj
->do_ToolTypes
[t
]);
226 printf ("--- none ---\n");
228 if (!PutDiskObject ("readicon", dobj
))
229 PrintFault (IoErr(), "Writing of icon to readicon.info failed");
233 FreeDiskObject (dobj
);
240 PrintFault(IoErr(), argv
[0]);