home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 15 / AACD15.ISO / AACD / Programming / BGUI / bgui_e / sources / examples / MultiFont.e < prev    next >
Encoding:
Text File  |  1999-08-26  |  8.2 KB  |  185 lines

  1. /*
  2.  *  MULTIFONT.E
  3.  *
  4.  *  (C) Copyright 1996 Marco Talamelli.
  5.  *      All Rights Reserved.
  6.  *
  7.  *  Modified by Dominique Dutoit to use more common fonts (times and helvetica).
  8.  *  Updated on 11-Aug-96
  9.  */
  10.  
  11. OPT OSVERSION=37
  12. OPT PREPROCESS
  13.  
  14. MODULE  'libraries/bgui',
  15.         'libraries/bguim',
  16.         'libraries/gadtools',
  17.         'bgui',
  18.         'bgui/bgui_image',
  19.         'diskfont',
  20.         'tools/boopsi',
  21.         'utility/tagitem',
  22.         'intuition/screens',
  23.         'intuition/intuition',
  24.         'intuition/classes',
  25.         'graphics/text',
  26.         'intuition/classusr',
  27.         'intuition/gadgetclass'
  28.  
  29. CONST   ID_QUIT=1
  30.  
  31. PROC main()
  32.  
  33.     DEF button:PTR TO textfont,info1:PTR TO textfont,info2:PTR TO textfont,
  34.         window:PTR TO window,
  35.         wo_window, go_quit,
  36.         signal, rc,
  37.         running = TRUE
  38.  
  39.     /*
  40.     **      Open the library.
  41.     **/
  42.     IF bguibase := OpenLibrary( 'bgui.library', BGUIVERSION )
  43.  
  44.         /*
  45.          *  We need this one to open the fonts.
  46.          */
  47.         IF diskfontbase := OpenLibrary( 'diskfont.library', 36 )
  48.             /*
  49.              *  We open the fonts ourselves since BGUI
  50.              *  opens all fonts with OpenFont() which
  51.              *  means that they have to be resident
  52.              *  in memory.
  53.              */
  54.             IF button := OpenDiskFont( [ 'helvetica.font', 13, FS_NORMAL, FPF_DISKFONT ]:textattr )
  55.                 IF info1 := OpenDiskFont( [ 'times.font', 15, FS_NORMAL, FPF_DISKFONT ]:textattr )
  56.                     IF info2 := OpenDiskFont( [ 'helvetica.font', 24,  FS_NORMAL, FPF_DISKFONT ]:textattr )
  57.                         /*
  58.                          *  Create the window object.
  59.                          */
  60.                         wo_window := WindowObject,
  61.                             WINDOW_Title,           'Multi-Font Demo',
  62.                             WINDOW_AutoAspect,      TRUE,
  63.                             WINDOW_LockHeight,      TRUE,
  64.                             WINDOW_RMBTrap,         TRUE,
  65.                             WINDOW_AutoKeyLabel,    TRUE,
  66.                             WINDOW_MasterGroup,
  67.                                 VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ), GROUP_BackFill, SHINE_RASTER,
  68.                                     StartMember,
  69.                                         VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 2 ),
  70.                                             FRM_Type,       FRTYPE_BUTTON,
  71.                                             FRM_Recessed,       TRUE,
  72.                                             StartMember,
  73.                                                 InfoObject,
  74.                                                     INFO_TextFormat,    '\ec\ed8MultiFont',
  75.                                                     INFO_HorizOffset,   0,
  76.                                                     INFO_VertOffset,    0,
  77.                                                     INFO_FixTextWidth,  TRUE,
  78.                                                     INFO_MinLines,      1,
  79.                                                     BT_TextAttr,        [ 'helvetica.font', 24, FS_NORMAL, FPF_DISKFONT ]:textattr,
  80.                                                 EndObject,
  81.                                             EndMember,
  82.                                             StartMember,
  83.                                                 SeperatorObject,SEP_Horiz,TRUE,EndObject, FixMinHeight,
  84.                                             EndMember,
  85.  
  86.                                             StartMember,
  87.                                                 InfoObject,
  88.                                                     INFO_TextFormat,    '\ecThis demo shows you how you\ncan use different fonts inside a\nsingle window.',
  89.                                                     INFO_HorizOffset,   0,
  90.                                                     INFO_VertOffset,    0,
  91.                                                     INFO_FixTextWidth,  TRUE,
  92.                                                     INFO_MinLines,      3,
  93.                                                     BT_TextAttr,        [ 'helvetica.font', 13,  FS_NORMAL, FPF_DISKFONT ]:textattr,
  94.                                                 EndObject,
  95.                                             EndMember,
  96.  
  97.                                         EndObject,
  98.                                     EndMember,
  99.                                     StartMember,
  100.                                         HGroupObject,
  101.                                             VarSpace( 50 ),
  102.  
  103.                                             StartMember,
  104.                                                 go_quit := ButtonObject,
  105.                                                     LAB_Label,  '_Quit',
  106.                                                     LAB_Underscore, "_",
  107.                                                     ButtonFrame,
  108.                                                     GA_ID,      ID_QUIT,
  109.                                                     BT_TextAttr,    [ 'times.font', 15, FS_NORMAL, FPF_DISKFONT ]:textattr,
  110.                                                 EndObject,
  111.                                             EndMember,
  112.                                             VarSpace( 50 ),
  113.                                         EndObject, FixMinHeight,
  114.                                     EndMember,
  115.                                 EndObject,
  116.                         EndObject
  117.  
  118.                         /*
  119.                          *  Object created OK?
  120.                          */
  121.                         IF wo_window
  122.                             /*
  123.                              *  try to open the window.
  124.                              */
  125.                             IF window := WindowOpen( wo_window )
  126.                                 /*
  127.                                  *  Obtain it's wait mask.
  128.                                  */
  129.                                 GetAttr( WINDOW_SigMask, wo_window, {signal} )
  130.                                 /*
  131.                                  *  Event loop...
  132.                                  */
  133.                                 WHILE running = TRUE
  134.                                     Wait( signal )
  135.                                     /*
  136.                                      *  Handle events.
  137.                                      */
  138.                                     WHILE ( rc := HandleEvent( wo_window )) <> WMHI_NOMORE
  139.                                         /*
  140.                                          *  Evaluate return code.
  141.                                          */
  142.                                         SELECT rc
  143.  
  144.                                             CASE    WMHI_CLOSEWINDOW
  145.                                                 running := FALSE
  146.                                             CASE    ID_QUIT
  147.                                                 running := FALSE
  148.                                         ENDSELECT
  149.                                     ENDWHILE
  150.                                 ENDWHILE
  151.                             ELSE
  152.                                 WriteF('Could not open the window\n')
  153.                             ENDIF
  154.                             /*
  155.                              *  Disposing of the window object will
  156.                              *  also close the window if it is
  157.                              *  already opened and it will dispose of
  158.                              *  all objects attached to it.
  159.                              */
  160.                             DisposeObject( wo_window )
  161.                         ELSE
  162.                             WriteF('Could not create the window object\n')
  163.                         ENDIF
  164.                         CloseFont( info2 )
  165.                     ELSE
  166.                         WriteF('Could not open helvetica.font, 24\n')
  167.                     ENDIF
  168.                     CloseFont( info1 )
  169.                 ELSE
  170.                     WriteF('Could not open times.font, 15\n')
  171.                 ENDIF
  172.                 CloseFont( button )
  173.             ELSE
  174.                 WriteF('Could not open helvetica.font, 13\n')
  175.             ENDIF
  176.             CloseLibrary( diskfontbase )
  177.         ELSE
  178.             WriteF('Could not open diskfont.library\n')
  179.         ENDIF
  180.         CloseLibrary( bguibase )
  181.     ELSE
  182.         WriteF('Could not open the bgui.library\n')
  183.     ENDIF
  184. ENDPROC
  185.