build git 2.17.1
[AROS-Contrib.git] / bgui / examples / MultiFont.c
bloba15505ab86e0db7f7ac9e490671556ba90e889ff
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 IPTR signal;
62 ULONG rc;
63 BOOL running = TRUE;
66 * We need this one to open the fonts.
68 if (( DiskfontBase = OpenLibrary( "diskfont.library", 36 ))) {
70 * We open the fonts ourselves since BGUI
71 * opens all fonts with OpenFont() which
72 * means that they have to be resident
73 * in memory.
75 if (( Button = OpenDiskFont( &ButtonFont ))) {
76 if (( Info1 = OpenDiskFont( &Info1Font ))) {
77 if (( Info2 = OpenDiskFont( &Info2Font ))) {
79 * Create the window object.
81 WO_Window = WindowObject,
82 WINDOW_Title, "Multi-Font Demo",
83 WINDOW_AutoAspect, TRUE,
84 WINDOW_LockHeight, TRUE,
85 WINDOW_RMBTrap, TRUE,
86 WINDOW_MasterGroup,
87 VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill, SHINE_RASTER,
88 StartMember,
89 VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 2 ),
90 FRM_Type, FRTYPE_BUTTON,
91 FRM_Recessed, TRUE,
92 StartMember,
93 InfoObject,
94 INFO_TextFormat, IText1,
95 INFO_HorizOffset, 0,
96 INFO_VertOffset, 0,
97 INFO_FixTextWidth, TRUE,
98 INFO_MinLines, 1,
99 BT_TextAttr, &Info1Font,
100 EndObject,
101 EndMember,
102 StartMember,
103 HorizSeparator,
104 EndMember,
105 StartMember,
106 InfoObject,
107 INFO_TextFormat, IText2,
108 INFO_HorizOffset, 0,
109 INFO_VertOffset, 0,
110 INFO_FixTextWidth, TRUE,
111 INFO_MinLines, 3,
112 BT_TextAttr, &Info2Font,
113 EndObject,
114 EndMember,
115 EndObject,
116 EndMember,
117 StartMember,
118 HGroupObject,
119 VarSpace( 50 ),
120 StartMember,
121 GO_Quit = ButtonObject,
122 LAB_Label, "_Quit",
123 LAB_Underscore, '_',
124 ButtonFrame,
125 GA_ID, ID_QUIT,
126 BT_TextAttr, &ButtonFont,
127 EndObject,
128 EndMember,
129 VarSpace( 50 ),
130 EndObject, FixMinHeight,
131 EndMember,
132 EndObject,
133 EndObject;
136 * Object created OK?
138 if ( WO_Window ) {
140 * Assign the key to the button.
142 if ( GadgetKey( WO_Window, GO_Quit, "q" )) {
144 * try to open the window.
146 if (( window = WindowOpen( WO_Window ))) {
148 * Obtain it's wait mask.
150 GetAttr( WINDOW_SigMask, WO_Window, &signal );
152 * Event loop...
154 do {
155 Wait( signal );
157 * Handle events.
159 while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
161 * Evaluate return code.
163 switch ( rc ) {
165 case WMHI_CLOSEWINDOW:
166 case ID_QUIT:
167 running = FALSE;
168 break;
171 } while ( running );
172 } else
173 Tell( "Could not open the window\n" );
174 } else
175 Tell( "Could not assign gadget keys\n" );
177 * Disposing of the window object will
178 * also close the window if it is
179 * already opened and it will dispose of
180 * all objects attached to it.
182 DisposeObject( WO_Window );
183 } else
184 Tell( "Could not create the window object\n" );
185 CloseFont( Info2 );
186 } else
187 Tell( "Could not open opal.font\n" );
188 CloseFont( Info1 );
189 } else
190 Tell( "Could not open emerald.font\n" );
191 CloseFont( Button );
192 } else
193 Tell( "Could not open diamond.font\n" );
194 CloseLibrary( DiskfontBase );
195 } else
196 Tell( "Could not open diskfont.library\n" );