home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************/
- /* */
- /* Amiga C Encyclopedia (ACE) V3.0 Amiga C Club (ACC) */
- /* ------------------------------- ------------------ */
- /* */
- /* Book: ACM Graphics Amiga C Club */
- /* Chapter: Fonts Tulevagen 22 */
- /* File: Example1.c 181 41 LIDINGO */
- /* Author: Anders Bjerin SWEDEN */
- /* Date: 92-04-28 */
- /* Version: 1.00 */
- /* */
- /* Copyright 1992, Anders Bjerin - Amiga C Club (ACC) */
- /* */
- /* Registered members may use this program freely in their */
- /* own commercial/noncommercial programs/articles. */
- /* */
- /***********************************************************/
-
- /* This example demonstrates how to open the ROM font "Topaz". (Topaz is */
- /* the standard system font, and is placed in ROM on all Amigas. If you */
- /* have told preferences to use a 60-character display the 9 pixel size */
- /* will be used, else (80-character display) the 8 pixel size will be */
- /* used. This example prints some text in both sizes. */
-
-
-
- #include <intuition/intuitionbase.h>
-
-
-
- struct Intuition *IntuitionBase; /* Running under Intuition. */
- struct GfxBase *GfxBase; /* Move() and Text(). */
-
-
-
- /* The new font's attributes: */
- struct TextAttr my_font_attr=
- {
- "topaz.font", /* Name of the font. */
- 9, /* Height (in pixels) */
- FS_NORMAL, /* Style */
- FPF_ROMFONT /* Exist in ROM. */
- };
-
- /* Pointer to our new font: */
- struct TextFont *my_font;
-
-
-
- /* Declare a pointer to a Window structure: */
- struct Window *my_window;
-
- /* Declare and initialize your NewWindow structure: */
- struct NewWindow my_new_window=
- {
- 0, /* LeftEdge x position of the window. */
- 12, /* TopEdge y positio of the window. */
- 640, /* Width 640 pixels wide. */
- 100, /* Height 100 lines high. */
- 0, /* DetailPen Text should be drawn with colour reg. 0 */
- 1, /* BlockPen Blocks should be drawn with colour reg. 1 */
- CLOSEWINDOW, /* IDCMPFlags The window will give us a message if the */
- /* user has selected the Close window gad. */
- SMART_REFRESH| /* Flags Intuition should refresh the window. */
- WINDOWCLOSE| /* Close Gadget. */
- WINDOWDRAG| /* Drag gadget. */
- WINDOWDEPTH| /* Depth arrange Gadgets. */
- ACTIVATE, /* The window should be Active when opened. */
- NULL, /* FirstGadget No Custom gadgets. */
- NULL, /* CheckMark Use Intuition's default CheckMark. */
- "FONT EXAMPLE (TOPAZ)", /* Title Title of the window. */
- NULL, /* Screen Connected to the Workbench Screen. */
- NULL, /* BitMap No Custom BitMap. */
- 0, /* MinWidth No sizing gadget. */
- 0, /* MinHeight -"- */
- 0, /* MaxWidth -"- */
- 0, /* MaxHeight -"- */
- WBENCHSCREEN /* Type Connected to the Workbench Screen. */
- };
-
-
-
- void main();
- void clean_up();
-
- void main()
- {
- BOOL close_me; /* Used in the loop. */
- ULONG class; /* IDCMP flag. */
- struct IntuiMessage *my_message; /* IntuiMessage structure. */
-
-
- /* Open the necessary libraries: */
- IntuitionBase = (struct IntuitionBase *)
- OpenLibrary( "intuition.library", 0 );
- if( !IntuitionBase )
- clean_up( "Could not open Intuition library!" );
-
- GfxBase = (struct GfxBase *)
- OpenLibrary( "graphics.library", 0 );
- if( !GfxBase )
- clean_up( "Could not open Graphics library!" );
-
-
- /* Open a window in which we will display the new font: */
- my_window = (struct Window *) OpenWindow( &my_new_window );
-
- /* Have we opened the window succesfully? */
- if(my_window == NULL)
- clean_up( "Could not open the window!" );
-
-
- /* Set colour and draw mode: */
- SetAPen( my_window->RPort, 1 );
- SetDrMd( my_window->RPort, JAM1 );
-
-
- /* Try to open a ROM font: */
- my_font = (struct TextFont *)
- OpenFont( &my_font_attr );
-
- /* Have we opened the font successfully? */
- if( !my_font )
- clean_up( "Could not open the font \"Topaz 9\"!" );
-
-
- /* Change the window's default font: */
- SetFont( my_window->RPort, my_font );
-
-
- /* Position the cursor, and print some characters: */
- Move( my_window->RPort, 5, 25 );
- Text( my_window->RPort, "Topaz, 9 pixels high.", 21 );
-
-
- /* Change the size to 8 pixels high: */
- my_font_attr.ta_YSize = 8;
-
-
- /* Try to open another ROM font: */
- my_font = (struct TextFont *)
- OpenFont( &my_font_attr );
-
- /* Have we opened the font successfully? */
- if( !my_font )
- clean_up( "Could not open the font \"Topaz 8\"!" );
-
-
- /* Change the window's default font: */
- SetFont( my_window->RPort, my_font );
-
-
- /* Position the cursor, and print some characters: */
- Move( my_window->RPort, 5, 35 );
- Text( my_window->RPort, "Topaz, 8 pixels high.", 21 );
-
-
- /* Wait until the user closes the window: */
- close_me = FALSE;
- while( close_me == FALSE )
- {
- /* Wait until we have recieved a message: */
- Wait( 1 << my_window->UserPort->mp_SigBit );
-
- /* Collect the message: */
- while( (my_message = (struct IntuiMessage *) GetMsg( my_window->UserPort )) )
- {
- /* After we have collected the message we can read it, and save any */
- /* important values which we maybe want to check later: */
- class = my_message->Class;
-
- /* After we have read it we reply as fast as possible: */
- /* REMEMBER! Do never try to read a message after you have replied! */
- /* Some other process has maybe changed it. */
- ReplyMsg( my_message );
-
- /* Check which IDCMP flag was sent: */
- if( class == CLOSEWINDOW )
- close_me=TRUE; /* The user selected the Close window gadget! */
- }
- }
-
-
- clean_up( "The End" );
- }
-
- void clean_up( message )
- STRPTR message;
- {
- if( my_window )
- CloseWindow( my_window );
-
- if( my_font )
- CloseFont( my_font );
-
- if( GfxBase )
- CloseLibrary( GfxBase );
-
- if( IntuitionBase )
- CloseLibrary( IntuitionBase );
-
- printf( "%s\n", message );
-
- exit();
- }
-
-