home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / software / sviluppo / mcc_speedbar / developer / c / examples / demo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-22  |  8.0 KB  |  193 lines

  1. /*
  2. ** $Id: Demo.c,v 1.5 1999/08/05 16:56:11 wiz Exp $
  3. */
  4.  
  5. /// Include
  6. #include <exec/types.h>             //  exec
  7. #include <exec/libraries.h>
  8. #include <exec/memory.h>
  9. #include <dos/dos.h>                //  dos
  10. #include <libraries/mui.h>          //  libraries
  11. #include <clib/muimaster_protos.h>  //  clib
  12. #include <clib/alib_protos.h>
  13. #include <proto/exec.h>             //  proto
  14. #include <proto/dos.h>
  15. #include <proto/muimaster.h>
  16.  
  17. #include <string.h>
  18. #include <stdio.h>
  19.  
  20. #include "/SpeedBar_mcc.h"
  21. #include "MyBrush.h"
  22. ///
  23. /// Data
  24. struct Library *MUIMasterBase;
  25. ///
  26.  
  27.  
  28. /// MakeLabel1
  29. Object *MakeLabel1( STRPTR str )
  30. {
  31.     return( MUI_MakeObject( MUIO_Label, str, MUIO_Label_SingleFrame ));
  32. }
  33. ///
  34. /// MakeCheck
  35. Object *MakeCheck( STRPTR str )
  36. {
  37.     Object *obj = MUI_MakeObject( MUIO_Checkmark, str );
  38.  
  39.     if( obj )
  40.         set( obj, MUIA_CycleChain, TRUE );
  41.  
  42.     return( obj );
  43. }
  44. ///
  45. /// MakeCycle
  46. Object *MakeCycle( STRPTR *array, STRPTR txt )
  47. {
  48.     Object *obj = MUI_MakeObject( MUIO_Cycle, txt, array );
  49.  
  50.     if( obj )
  51.         set( obj, MUIA_CycleChain, TRUE );
  52.  
  53.     return( obj );
  54. }
  55. ///
  56.  
  57.  
  58. int main( int argc, char *argv[] )
  59. {
  60.     Object                             *AppObj, *MainWin, *SpeedBar;
  61.     Object                             *viewmode, *borderless, *raising, *small, *sunny;
  62.     static struct MUIS_SpeedBar_Button  buttons[] = {
  63.                                             { 0, "Toggle",    "Toggle mode example",      MUIV_SpeedBar_ButtonFlag_Toggle,    NULL },
  64.                                             { 1, "Immediate", "Immediate mode example",   MUIV_SpeedBar_ButtonFlag_Immediate, NULL },
  65.                                             { MUIV_SpeedBar_Spacer },
  66.                                             { 2, "Quit",      "This will quit the program", 0, NULL },
  67.                                             { 2, "Disabled",  "This does nothing at all",   MUIV_SpeedBar_ButtonFlag_Disabled, NULL },
  68.                                             { MUIV_SpeedBar_End },
  69.                                         };
  70.     static STRPTR                       Modes[] = {
  71.                                             "Text + Graphics",
  72.                                             "Graphics only",
  73.                                             "Text only",
  74.                                             NULL
  75.                                         };
  76.     static STRPTR                       Files[] = {
  77.                                             "Pic1.iff",
  78.                                             "Pic2.iff",
  79.                                             "Pic3.iff",
  80.                                             "Spacer.iff"
  81.                                         };
  82.     ULONG                               i;
  83.     struct MyBrush                     *Brushes[4] = { 0 };
  84.  
  85.     if(!( MUIMasterBase = OpenLibrary( "muimaster.library", 19 )))
  86.         return( 20 );
  87.  
  88.     for( i = 0; i < 4; i++ )
  89.         Brushes[ i ] = LoadBrush( Files[ i ]);
  90.  
  91.     if( AppObj = ApplicationObject,
  92.  
  93.                         MUIA_Application_Title,         "SpeedBar Test",
  94.                         MUIA_Application_Version,       "$VER: SpeedBarTest 1.0 (31.7.99)",
  95.                         MUIA_Application_Copyright,     "Copyright ©1999 by Simone Tellini",
  96.                         MUIA_Application_Author,        "Simone Tellini <wiz@vapor.com>",
  97.                         MUIA_Application_Description,   "Speed(Bar|Button).mcc test program",
  98.                         MUIA_Application_Base,          "SPEEDBARTEST",
  99.  
  100.                         SubWindow, MainWin = WindowObject,
  101.  
  102.                             MUIA_Window_ID,             MAKE_ID( 'M', 'A', 'I', 'N' ),
  103.                             MUIA_Window_Title,          "SpeedBarTest - ©1999 Simone Tellini",
  104.  
  105.                             WindowContents, VGroup,
  106.  
  107.                                 Child, HGroup,
  108.  
  109.                                     Child, SpeedBar = SpeedBarObject,
  110.                                         MUIA_Group_Horiz,           TRUE,
  111.                                         MUIA_SpeedBar_Images,       Brushes,
  112.                                         MUIA_SpeedBar_Borderless,   FALSE,
  113.                                         MUIA_SpeedBar_ViewMode,     MUIV_SpeedBar_ViewMode_TextGfx,
  114.                                         MUIA_SpeedBar_RaisingFrame, FALSE,
  115.                                         MUIA_SpeedBar_Buttons,      buttons,
  116.                                         MUIA_SpeedBar_SpacerIndex,  3, // -1,
  117.                                         MUIA_SpeedBar_Spread,       FALSE, //TRUE,
  118.                                     End,
  119.  
  120.                                     Child, HSpace( 0 ),
  121.                                 End,
  122.  
  123.                                 Child, ColGroup( 2 ),
  124.  
  125.                                     Child, MakeLabel1( "_Borderless" ),
  126.                                     Child, HGroup,
  127.                                         Child, borderless = MakeCheck( "_Borderless" ),
  128.                                         Child, HSpace( 0 ),
  129.                                     End,
  130.  
  131.                                     Child, MakeLabel1( "_Raising frames" ),
  132.                                     Child, HGroup,
  133.                                         Child, raising = MakeCheck( "_Raising frames" ),
  134.                                         Child, HSpace( 0 ),
  135.                                     End,
  136.  
  137.                                     Child, MakeLabel1( "_View Mode" ),
  138.                                     Child, HGroup,
  139.                                         Child, viewmode = MakeCycle( Modes, "_View Mode" ),
  140.                                         Child, HSpace( 0 ),
  141.                                     End,
  142.  
  143.                                     Child, MakeLabel1( "Small _images" ),
  144.                                     Child, HGroup,
  145.                                         Child, small = MakeCheck( "Small _images" ),
  146.                                         Child, HSpace( 0 ),
  147.                                     End,
  148.  
  149.                                     Child, MakeLabel1( "_Sunny" ),
  150.                                     Child, HGroup,
  151.                                         Child, sunny = MakeCheck( "_Sunny" ),
  152.                                         Child, HSpace( 0 ),
  153.                                     End,
  154.                                 End,
  155.                             End,
  156.                         End,
  157.                    End ) {
  158.         ULONG   sigs = 0;
  159.  
  160.         DoMethod( MainWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  161.  
  162.         DoMethod( buttons[ 0 ].Object, MUIM_Notify, MUIA_Selected, FALSE, SpeedBar, 5, MUIM_SpeedBar_DoOnButton, 1, MUIM_Set, MUIA_Selected, FALSE );
  163.         DoMethod( buttons[ 3 ].Object, MUIM_Notify, MUIA_Pressed, FALSE, AppObj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
  164.  
  165.         DoMethod( borderless, MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_Borderless,   MUIV_TriggerValue );
  166.         DoMethod( raising,    MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_RaisingFrame, MUIV_TriggerValue );
  167.         DoMethod( viewmode,   MUIM_Notify, MUIA_Cycle_Active, MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_ViewMode,     MUIV_TriggerValue );
  168.         DoMethod( small,      MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_SmallImages,  MUIV_TriggerValue );
  169.         DoMethod( sunny,      MUIM_Notify, MUIA_Selected,     MUIV_EveryTime, SpeedBar, 3, MUIM_Set, MUIA_SpeedBar_Sunny,        MUIV_TriggerValue );
  170.  
  171.         set( MainWin, MUIA_Window_Open, TRUE );
  172.  
  173.         while( DoMethod( AppObj, MUIM_Application_NewInput, &sigs ) != MUIV_Application_ReturnID_Quit ) {
  174.             if( sigs ) {
  175.  
  176.                 sigs = Wait( sigs | SIGBREAKF_CTRL_C );
  177.  
  178.                 if( sigs & SIGBREAKF_CTRL_C )
  179.                     break;
  180.             }
  181.         }
  182.  
  183.         MUI_DisposeObject( AppObj );
  184.     }
  185.  
  186.     for( i = 0; i < 4; i++ )
  187.         FreeBrush( Brushes[ i ]);
  188.  
  189.     CloseLibrary( MUIMasterBase );
  190.  
  191.     return( 0 );
  192. }
  193.