Replaced System by SYS because on "native" the volume name of the system partition...
[AROS-Contrib.git] / bgui / examples / MultiFont.c
blobe8fb43174f178b5527ea10e6bce7f395a78816d4
1 /*
2 * @(#) $Header$
4 * MultiFont.c
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.0 2000/05/09 22:20:00 mlemos
13 * Bumped to revision 42.0 before handing BGUI to AROS team
15 * Revision 41.11 2000/05/09 20:33:49 mlemos
16 * Bumped to revision 41.11
18 * Revision 1.2 2000/05/09 19:59:06 mlemos
19 * Merged with the branch Manuel_Lemos_fixes.
21 * Revision 1.1.2.1 1998/02/28 17:45:34 mlemos
22 * Ian sources
28 dcc MultiFont.c -mi -ms -mRR -proto -lbgui
29 quit
32 #include "DemoCode.h"
35 * Fonts used in the code.
37 struct TextAttr ButtonFont = { "diamond.font", 12, FS_NORMAL, FPF_DISKFONT };
38 struct TextAttr Info1Font = { "emerald.font", 17, FS_NORMAL, FPF_DISKFONT };
39 struct TextAttr Info2Font = { "opal.font", 9, FS_NORMAL, FPF_DISKFONT };
41 struct TextFont *Button, *Info1, *Info2;
42 struct Library *DiskfontBase;
45 * Object ID's
47 #define ID_QUIT 1
50 * Info texts.
52 UBYTE *IText1 = ISEQ_C ISEQ_HIGHLIGHT "MultiFont";
53 UBYTE *IText2 = ISEQ_C "This demo shows you how you\n"
54 "can use different fonts inside a\n"
55 "single window.";
57 VOID StartDemo( void )
59 struct Window *window;
60 Object *WO_Window, *GO_Quit;
61 ULONG signal, rc;
62 BOOL running = TRUE;
65 * We need this one to open the fonts.
67 if ( DiskfontBase = OpenLibrary( "diskfont.library", 36 )) {
69 * We open the fonts ourselves since BGUI
70 * opens all fonts with OpenFont() which
71 * means that they have to be resident
72 * in memory.
74 if ( Button = OpenDiskFont( &ButtonFont )) {
75 if ( Info1 = OpenDiskFont( &Info1Font )) {
76 if ( Info2 = OpenDiskFont( &Info2Font )) {
78 * Create the window object.
80 WO_Window = WindowObject,
81 WINDOW_Title, "Multi-Font Demo",
82 WINDOW_AutoAspect, TRUE,
83 WINDOW_LockHeight, TRUE,
84 WINDOW_RMBTrap, TRUE,
85 WINDOW_MasterGroup,
86 VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill, SHINE_RASTER,
87 StartMember,
88 VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 2 ),
89 FRM_Type, FRTYPE_BUTTON,
90 FRM_Recessed, TRUE,
91 StartMember,
92 InfoObject,
93 INFO_TextFormat, IText1,
94 INFO_HorizOffset, 0,
95 INFO_VertOffset, 0,
96 INFO_FixTextWidth, TRUE,
97 INFO_MinLines, 1,
98 BT_TextAttr, &Info1Font,
99 EndObject,
100 EndMember,
101 StartMember,
102 HorizSeparator,
103 EndMember,
104 StartMember,
105 InfoObject,
106 INFO_TextFormat, IText2,
107 INFO_HorizOffset, 0,
108 INFO_VertOffset, 0,
109 INFO_FixTextWidth, TRUE,
110 INFO_MinLines, 3,
111 BT_TextAttr, &Info2Font,
112 EndObject,
113 EndMember,
114 EndObject,
115 EndMember,
116 StartMember,
117 HGroupObject,
118 VarSpace( 50 ),
119 StartMember,
120 GO_Quit = ButtonObject,
121 LAB_Label, "_Quit",
122 LAB_Underscore, '_',
123 ButtonFrame,
124 GA_ID, ID_QUIT,
125 BT_TextAttr, &ButtonFont,
126 EndObject,
127 EndMember,
128 VarSpace( 50 ),
129 EndObject, FixMinHeight,
130 EndMember,
131 EndObject,
132 EndObject;
135 * Object created OK?
137 if ( WO_Window ) {
139 * Assign the key to the button.
141 if ( GadgetKey( WO_Window, GO_Quit, "q" )) {
143 * try to open the window.
145 if ( window = WindowOpen( WO_Window )) {
147 * Obtain it's wait mask.
149 GetAttr( WINDOW_SigMask, WO_Window, &signal );
151 * Event loop...
153 do {
154 Wait( signal );
156 * Handle events.
158 while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
160 * Evaluate return code.
162 switch ( rc ) {
164 case WMHI_CLOSEWINDOW:
165 case ID_QUIT:
166 running = FALSE;
167 break;
170 } while ( running );
171 } else
172 Tell( "Could not open the window\n" );
173 } else
174 Tell( "Could not assign gadget keys\n" );
176 * Disposing of the window object will
177 * also close the window if it is
178 * already opened and it will dispose of
179 * all objects attached to it.
181 DisposeObject( WO_Window );
182 } else
183 Tell( "Could not create the window object\n" );
184 CloseFont( Info2 );
185 } else
186 Tell( "Could not open opal.font\n" );
187 CloseFont( Info1 );
188 } else
189 Tell( "Could not open emerald.font\n" );
190 CloseFont( Button );
191 } else
192 Tell( "Could not open diamond.font\n" );
193 CloseLibrary( DiskfontBase );
194 } else
195 Tell( "Could not open diskfont.library\n" );