grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / demos / intuitext.c
blob3b38705ce21c4c6aba81995e3a1514c77d4aff24
1 ;/* intuitext.c - Execute me to compile me with SAS C 5.10
2 LC -b1 -cfistq -v -y -j73 intuitext.c
3 Blink FROM LIB:c.o,intuitext.o TO intuitext LIBRARY LIB:LC.lib,LIB:Amiga.lib
4 quit
5 */
7 /*
8 Copyright (c) 1992 Commodore-Amiga, Inc.
10 This example is provided in electronic form by Commodore-Amiga, Inc. for
11 use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
12 published by Addison-Wesley (ISBN 0-201-56774-1).
14 The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
15 information on the correct usage of the techniques and operating system
16 functions presented in these examples. The source and executable code
17 of these examples may only be distributed in free electronic form, via
18 bulletin board or as part of a fully non-commercial and freely
19 redistributable diskette. Both the source and executable code (including
20 comments) must be included, without modification, in any copy. This
21 example may not be published in printed form or distributed with any
22 commercial product. However, the programming techniques and support
23 routines set forth in these examples may be used in the development
24 of original executable software products for Commodore Amiga computers.
26 All other rights reserved.
28 This example is provided "as-is" and is subject to change; no
29 warranties are made. All use is at your own risk. No liability or
30 responsibility is assumed.
35 ** intuitext.c - program to show the use of an Intuition IntuiText object.
37 #define INTUI_V36_NAMES_ONLY
39 #include <exec/types.h>
40 #include <intuition/intuition.h>
42 #include <proto/exec.h>
43 #include <proto/dos.h>
44 #include <proto/intuition.h>
46 #include <stdio.h>
48 static const char version[] __attribute__((used)) = "$VER: intuitext 41.1 (14.3.1997)\n";
50 #ifdef __AROS__
51 #ifdef __chip
52 #undef __chip
53 #endif
54 #define __chip
55 #include <proto/alib.h>
56 #endif
58 #ifdef LATTICE
59 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
60 int chkabort(void) { return(0); } /* really */
61 #endif
63 struct IntuitionBase *IntuitionBase = NULL;
65 #define MYTEXT_LEFT (0)
66 #define MYTEXT_TOP (0)
69 ** main routine. Open required library and window and draw the images.
70 ** This routine opens a very simple window with no IDCMP. See the
71 ** chapters on "Windows" and "Input and Output Methods" for more info.
72 ** Free all resources when done.
74 int main(int argc, char **argv)
76 struct Screen *screen;
77 struct DrawInfo *drawinfo;
78 struct Window *win;
79 struct IntuiText myIText;
80 struct TextAttr myTextAttr;
82 ULONG myTEXTPEN;
83 ULONG myBACKGROUNDPEN;
85 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37);
86 if (IntuitionBase)
88 #ifdef __AROS__
89 if ((screen = LockPubScreen(NULL)))
90 #else
91 if (screen = LockPubScreen(NULL))
92 #endif
94 #ifdef __AROS__
95 if ((drawinfo = GetScreenDrawInfo(screen)))
96 #else
97 if (drawinfo = GetScreenDrawInfo(screen))
98 #endif
100 /* Get a copy of the correct pens for the screen.
101 ** This is very important in case the user or the
102 ** application has the pens set in a unusual way.
104 myTEXTPEN = drawinfo->dri_Pens[TEXTPEN];
105 myBACKGROUNDPEN = drawinfo->dri_Pens[BACKGROUNDPEN];
107 /* create a TextAttr that matches the specified font. */
108 myTextAttr.ta_Name = drawinfo->dri_Font->tf_Message.mn_Node.ln_Name;
109 myTextAttr.ta_YSize = drawinfo->dri_Font->tf_YSize;
110 myTextAttr.ta_Style = drawinfo->dri_Font->tf_Style;
111 myTextAttr.ta_Flags = drawinfo->dri_Font->tf_Flags;
113 /* open a simple window on the workbench screen for displaying
114 ** a text string. An application would probably never use such a
115 ** window, but it is useful for demonstrating graphics...
117 #ifdef __AROS__
118 if ((win = OpenWindowTags(NULL,
119 WA_PubScreen, (IPTR)screen,
120 WA_RMBTrap, TRUE,
121 WA_IDCMP, IDCMP_RAWKEY,
122 TAG_END)))
123 #else
124 if (win = OpenWindowTags(NULL,
125 WA_PubScreen, screen,
126 WA_RMBTrap, TRUE,
127 TAG_END))
128 #endif
130 myIText.FrontPen = myTEXTPEN;
131 myIText.BackPen = myBACKGROUNDPEN;
132 myIText.DrawMode = JAM2;
133 myIText.LeftEdge = MYTEXT_LEFT;
134 myIText.TopEdge = MYTEXT_TOP;
135 myIText.ITextFont = &myTextAttr;
136 myIText.IText = "Hello, World. ;-)";
137 myIText.NextText = NULL;
139 /* Draw the text string at 10,10 */
140 PrintIText(win->RPort,&myIText,10,10);
142 #ifdef __AROS__
143 /* Wait for keypress */
144 Wait (1L << win->UserPort->mp_SigBit);
145 #else
146 /* Wait a bit, then quit.
147 ** In a real application, this would be an event loop,
148 ** like the one described in the Intuition Input and
149 ** Output Methods chapter.
151 Delay(200);
152 #endif
154 CloseWindow(win);
156 FreeScreenDrawInfo(screen,drawinfo);
158 UnlockPubScreen(NULL,screen);
160 CloseLibrary((struct Library *)IntuitionBase);
162 return 0;