build git 2.17.1
[AROS-Contrib.git] / bgui / examples / DemoCode.h
blob8aa8de9b15e8dc9fe11151b17d61719a9a2afe09
1 /*
2 * @(#) $Header$
4 * DemoCode.h
6 * (C) Copyright 1998 Manuel Lemos.
7 * (C) Copyright 1995 Jaba Development.
8 * (C) Copyright 1995 Jan van den Baard.
9 * All Rights Reserved.
11 * $Log$
12 * Revision 42.8 2003/01/18 19:10:11 chodorowski
13 * Instead of using the _AROS or __AROS preprocessor symbols, use __AROS__.
15 * Revision 42.7 2000/08/10 17:53:19 stegerg
16 * removed a debug output.
18 * Revision 42.6 2000/08/08 20:36:51 stegerg
19 * UtilityBase on AROS is not of type struct Library *, but
20 * struct UtilityBase *. BTW: Why????????? I think we should
21 * fix this. Also locale.library seems to have this "problem".
23 * Revision 42.5 2000/08/08 19:29:54 chodorowski
24 * Minor changes.
26 * Revision 42.4 2000/08/08 13:51:34 chodorowski
27 * Removed all REGFUNC, REGPARAM and REG macros. Now includes
28 * contrib/bgui/compilerspecific.h where they are defined.
30 * Revision 42.3 2000/08/07 21:49:06 stegerg
31 * fixed/activated REGFUNC/REGPARAM macros.
33 * Revision 42.2 2000/07/04 05:02:22 bergers
34 * Made examples compilable.
36 * Revision 42.1 2000/05/15 19:28:19 stegerg
37 * REG() macro replacementes
39 * Revision 42.0 2000/05/09 22:19:38 mlemos
40 * Bumped to revision 42.0 before handing BGUI to AROS team
42 * Revision 41.11 2000/05/09 20:33:28 mlemos
43 * Bumped to revision 41.11
45 * Revision 1.2 2000/05/09 19:58:47 mlemos
46 * Merged with the branch Manuel_Lemos_fixes.
48 * Revision 1.1.2.2 1999/02/19 05:03:50 mlemos
49 * Added support to build with Storm C.
51 * Revision 1.1.2.1 1998/02/28 17:45:49 mlemos
52 * Ian sources
57 #include <exec/types.h>
58 #include <exec/memory.h>
59 #include <dos/dos.h>
60 #include <libraries/gadtools.h>
61 #include <libraries/bgui.h>
62 #include <libraries/bgui_macros.h>
63 #include <intuition/sghooks.h>
64 #ifndef __STORM__
65 #include <graphics/gfxmacros.h>
66 #endif
67 #include <workbench/workbench.h>
68 #include <workbench/startup.h>
70 #include <clib/alib_protos.h>
72 #include <proto/exec.h>
73 #include <proto/intuition.h>
74 #include <proto/dos.h>
75 #include <proto/bgui.h>
76 #include <proto/graphics.h>
77 #include <proto/diskfont.h>
78 #include <proto/utility.h>
80 #ifdef __STORM__
81 #include <graphics/gfxmacros.h>
82 #endif
84 #include <stdlib.h>
85 #include <stdio.h>
88 * The entry point of all demo programs.
90 extern VOID StartDemo( void );
93 * Output file handle and BGUI
94 * library base.
97 BPTR StdOut;
99 struct Library *BGUIBase;
101 #ifdef __AROS__
102 struct IntuitionBase *IntuitionBase;
103 struct GfxBase *GfxBase;
104 struct UtilityBase *UtilityBase;
105 #endif
108 * Output text to the CLI or Workbench console.
110 #define Tell(fstr, args...) do { \
111 if ( StdOut ) FPrintf( StdOut, fstr ,##args); \
112 } while (0)
114 BOOL openlibs(void)
116 IntuitionBase = (struct IntuitionBase *) OpenLibrary( "intuition.library", 0 );
117 GfxBase = (struct GfxBase *) OpenLibrary( "graphics.library", 0 );
118 UtilityBase = (APTR)OpenLibrary( "utility.library", 0 );
120 if (!IntuitionBase || !GfxBase || ! UtilityBase)
121 return FALSE;
123 return TRUE;
126 void closelibs(void)
128 if (IntuitionBase) CloseLibrary((struct Library*)IntuitionBase);
129 if (GfxBase) CloseLibrary((struct Library*)GfxBase);
130 if (UtilityBase) CloseLibrary((struct Library*)UtilityBase );
134 * Main entry point.
136 int main( int argc, char **argv )
138 struct Process *this_task = ( struct Process * )FindTask( NULL );
139 BOOL is_wb = FALSE;
141 if (FALSE == openlibs())
143 closelibs();
144 return -1;
147 if ( this_task->pr_CLI )
149 * Started from the CLI. Simply pickup
150 * the CLI output handle.
152 StdOut = Output();
153 else {
155 * Workbench startup. Open a console
156 * for output.
158 StdOut = Open( "CON:10/10/500/100/BGUI Demo Output/WAIT/AUTO", MODE_NEWFILE );
159 is_wb = TRUE;
163 * Open BGUI.
165 if (( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION ))) {
167 * Run the demo.
169 StartDemo();
170 CloseLibrary( BGUIBase );
171 } else
172 Tell( "Unable to open %s version %ld\n", BGUINAME, BGUIVERSION );
175 * Close console if ran from
176 * the workbench.
178 if ( is_wb ) {
179 if ( StdOut ) Close( StdOut );
182 return( 0 );
186 * DICE stub which simply calls
187 * main() when run from the
188 * workbench.
190 #if _DCC || __STORM__
191 int wbmain( struct WBStartup *wbs )
193 return( main( NULL, 0 ));
195 #endif
197 #define FuzzButton(label,id) ButtonObject, LAB_Label, label, LAB_Underscore, '_',\
198 GA_ID, id, FuzzButtonFrame, EndObject