home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / CDTools / ClassAct / Examples / Speed / SpeedExample1.c < prev    next >
C/C++ Source or Header  |  1997-07-09  |  11KB  |  455 lines

  1. /* ClassAct Example
  2.  * Copyright © 1995 Christopher Aldi
  3.  * All Rights Reserved.
  4.  *
  5.  * This Example Shows ClassAct's speed laying out & rendering 100 buttons.
  6.  */
  7.  
  8. #include <clib/macros.h>
  9. #include <clib/alib_protos.h>
  10.  
  11. #include <proto/exec.h>
  12. #include <proto/dos.h>
  13. #include <proto/utility.h>
  14. #include <proto/graphics.h>
  15. #include <proto/intuition.h>
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20.  
  21. #include <proto/window.h>
  22. #include <classes/window.h>
  23.  
  24. #include <libraries/gadtools.h>
  25. #include <classact.h>
  26. #include <classact_author.h>
  27.  
  28. struct ClassLibrary *WindowBase;
  29. struct ClassLibrary *LayoutBase;
  30. struct ClassLibrary *ButtonBase;
  31.  
  32. LONG ARG[1];
  33.  
  34. int main( void )
  35. {
  36.     struct Window *window;
  37.     Object *Win_Object;
  38.     ULONG signal, result;
  39.     ULONG done = FALSE;
  40.     struct RDArgs *args;
  41.     
  42.     if (!(args = ReadArgs("ND=NODEFER/S",ARG,NULL)))
  43.         return 20;
  44.  
  45.     /* Open the classes we will use. Note, classlib.lib SAS/C or DICE autoinit
  46.      * can do this for you automatically.
  47.      */
  48.     if( WindowBase = (struct ClassLibrary *)OpenLibrary("window.class",0L) )
  49.     {
  50.         if( LayoutBase = (struct ClassLibrary *)OpenLibrary("gadgets/layout.gadget",0L) )
  51.         {
  52.             if( ButtonBase = (struct ClassLibrary *)OpenLibrary("gadgets/button.gadget",0L) )
  53.             {
  54.                 /* Create the window object.
  55.                  */
  56.                 Win_Object = WindowObject,
  57.                     WA_ScreenTitle, "ClassAct Copyright 1995, Phantom Development LLC.",
  58.                     WA_Title, "SpeedTest1 (100 buttons)",
  59.                     WA_SizeGadget, TRUE,
  60.                     WA_Left, 40,
  61.                     WA_Top, 30,
  62.                     WA_DepthGadget, TRUE,
  63.                     WA_DragBar, TRUE,
  64.                     WA_CloseGadget, TRUE,
  65.                     WA_Activate, TRUE,
  66.                     WINDOW_ParentGroup, HGroupObject,
  67.                         TAligned, 
  68.                         LAYOUT_SpaceOuter, TRUE,
  69.                         LAYOUT_DeferLayout, !ARG[0],
  70.                         StartVGroup,
  71.                             StartMember, ButtonObject,
  72.                                 GA_Text, "Button",
  73.                             EndMember,
  74.                             StartMember, ButtonObject,
  75.                                 GA_Text, "Button",
  76.                             EndMember,
  77.                             StartMember, ButtonObject,
  78.                                 GA_Text, "Button",
  79.                             EndMember,
  80.                             StartMember, ButtonObject,
  81.                                 GA_Text, "Button",
  82.                             EndMember,
  83.                             StartMember, ButtonObject,
  84.                                 GA_Text, "Button",
  85.                             EndMember,
  86.                             StartMember, ButtonObject,
  87.                                 GA_Text, "Button",
  88.                             EndMember,
  89.                             StartMember, ButtonObject,
  90.                                 GA_Text, "Button",
  91.                             EndMember,
  92.                             StartMember, ButtonObject,
  93.                                 GA_Text, "Button",
  94.                             EndMember,
  95.                             StartMember, ButtonObject,
  96.                                 GA_Text, "Button",
  97.                             EndMember,
  98.                             StartMember, ButtonObject,
  99.                                 GA_Text, "Button",
  100.                             EndMember,
  101.                         End,
  102.                         StartVGroup,
  103.                             StartMember, ButtonObject,
  104.                                 GA_Text, "Button",
  105.                             EndMember,
  106.                             StartMember, ButtonObject,
  107.                                 GA_Text, "Button",
  108.                             EndMember,
  109.                             StartMember, ButtonObject,
  110.                                 GA_Text, "Button",
  111.                             EndMember,
  112.                             StartMember, ButtonObject,
  113.                                 GA_Text, "Button",
  114.                             EndMember,
  115.                             StartMember, ButtonObject,
  116.                                 GA_Text, "Button",
  117.                             EndMember,
  118.                             StartMember, ButtonObject,
  119.                                 GA_Text, "Button",
  120.                             EndMember,
  121.                             StartMember, ButtonObject,
  122.                                 GA_Text, "Button",
  123.                             EndMember,
  124.                             StartMember, ButtonObject,
  125.                                 GA_Text, "Button",
  126.                             EndMember,
  127.                             StartMember, ButtonObject,
  128.                                 GA_Text, "Button",
  129.                             EndMember,
  130.                             StartMember, ButtonObject,
  131.                                 GA_Text, "Button",
  132.                             EndMember,
  133.                         End,
  134.                         StartVGroup,
  135.                             StartMember, ButtonObject,
  136.                                 GA_Text, "Button",
  137.                             EndMember,
  138.                             StartMember, ButtonObject,
  139.                                 GA_Text, "Button",
  140.                             EndMember,
  141.                             StartMember, ButtonObject,
  142.                                 GA_Text, "Button",
  143.                             EndMember,
  144.                             StartMember, ButtonObject,
  145.                                 GA_Text, "Button",
  146.                             EndMember,
  147.                             StartMember, ButtonObject,
  148.                                 GA_Text, "Button",
  149.                             EndMember,
  150.                             StartMember, ButtonObject,
  151.                                 GA_Text, "Button",
  152.                             EndMember,
  153.                             StartMember, ButtonObject,
  154.                                 GA_Text, "Button",
  155.                             EndMember,
  156.                             StartMember, ButtonObject,
  157.                                 GA_Text, "Button",
  158.                             EndMember,
  159.                             StartMember, ButtonObject,
  160.                                 GA_Text, "Button",
  161.                             EndMember,
  162.                             StartMember, ButtonObject,
  163.                                 GA_Text, "Button",
  164.                             EndMember,
  165.                         End,
  166.                         StartVGroup,
  167.                             StartMember, ButtonObject,
  168.                                 GA_Text, "Button",
  169.                             EndMember,
  170.                             StartMember, ButtonObject,
  171.                                 GA_Text, "Button",
  172.                             EndMember,
  173.                             StartMember, ButtonObject,
  174.                                 GA_Text, "Button",
  175.                             EndMember,
  176.                             StartMember, ButtonObject,
  177.                                 GA_Text, "Button",
  178.                             EndMember,
  179.                             StartMember, ButtonObject,
  180.                                 GA_Text, "Button",
  181.                             EndMember,
  182.                             StartMember, ButtonObject,
  183.                                 GA_Text, "Button",
  184.                             EndMember,
  185.                             StartMember, ButtonObject,
  186.                                 GA_Text, "Button",
  187.                             EndMember,
  188.                             StartMember, ButtonObject,
  189.                                 GA_Text, "Button",
  190.                             EndMember,
  191.                             StartMember, ButtonObject,
  192.                                 GA_Text, "Button",
  193.                             EndMember,
  194.                             StartMember, ButtonObject,
  195.                                 GA_Text, "Button",
  196.                             EndMember,
  197.                         End,
  198.                         StartVGroup,
  199.                             StartMember, ButtonObject,
  200.                                 GA_Text, "Button",
  201.                             EndMember,
  202.                             StartMember, ButtonObject,
  203.                                 GA_Text, "Button",
  204.                             EndMember,
  205.                             StartMember, ButtonObject,
  206.                                 GA_Text, "Button",
  207.                             EndMember,
  208.                             StartMember, ButtonObject,
  209.                                 GA_Text, "Button",
  210.                             EndMember,
  211.                             StartMember, ButtonObject,
  212.                                 GA_Text, "Button",
  213.                             EndMember,
  214.                             StartMember, ButtonObject,
  215.                                 GA_Text, "Button",
  216.                             EndMember,
  217.                             StartMember, ButtonObject,
  218.                                 GA_Text, "Button",
  219.                             EndMember,
  220.                             StartMember, ButtonObject,
  221.                                 GA_Text, "Button",
  222.                             EndMember,
  223.                             StartMember, ButtonObject,
  224.                                 GA_Text, "Button",
  225.                             EndMember,
  226.                             StartMember, ButtonObject,
  227.                                 GA_Text, "Button",
  228.                             EndMember,
  229.                         End,
  230.                         StartVGroup,
  231.                             StartMember, ButtonObject,
  232.                                 GA_Text, "Button",
  233.                             EndMember,
  234.                             StartMember, ButtonObject,
  235.                                 GA_Text, "Button",
  236.                             EndMember,
  237.                             StartMember, ButtonObject,
  238.                                 GA_Text, "Button",
  239.                             EndMember,
  240.                             StartMember, ButtonObject,
  241.                                 GA_Text, "Button",
  242.                             EndMember,
  243.                             StartMember, ButtonObject,
  244.                                 GA_Text, "Button",
  245.                             EndMember,
  246.                             StartMember, ButtonObject,
  247.                                 GA_Text, "Button",
  248.                             EndMember,
  249.                             StartMember, ButtonObject,
  250.                                 GA_Text, "Button",
  251.                             EndMember,
  252.                             StartMember, ButtonObject,
  253.                                 GA_Text, "Button",
  254.                             EndMember,
  255.                             StartMember, ButtonObject,
  256.                                 GA_Text, "Button",
  257.                             EndMember,
  258.                             StartMember, ButtonObject,
  259.                                 GA_Text, "Button",
  260.                             EndMember,
  261.                         End,
  262.                         StartVGroup,
  263.                             StartMember, ButtonObject,
  264.                                 GA_Text, "Button",
  265.                             EndMember,
  266.                             StartMember, ButtonObject,
  267.                                 GA_Text, "Button",
  268.                             EndMember,
  269.                             StartMember, ButtonObject,
  270.                                 GA_Text, "Button",
  271.                             EndMember,
  272.                             StartMember, ButtonObject,
  273.                                 GA_Text, "Button",
  274.                             EndMember,
  275.                             StartMember, ButtonObject,
  276.                                 GA_Text, "Button",
  277.                             EndMember,
  278.                             StartMember, ButtonObject,
  279.                                 GA_Text, "Button",
  280.                             EndMember,
  281.                             StartMember, ButtonObject,
  282.                                 GA_Text, "Button",
  283.                             EndMember,
  284.                             StartMember, ButtonObject,
  285.                                 GA_Text, "Button",
  286.                             EndMember,
  287.                             StartMember, ButtonObject,
  288.                                 GA_Text, "Button",
  289.                             EndMember,
  290.                             StartMember, ButtonObject,
  291.                                 GA_Text, "Button",
  292.                             EndMember,
  293.                         End,
  294.                         StartVGroup,
  295.                             StartMember, ButtonObject,
  296.                                 GA_Text, "Button",
  297.                             EndMember,
  298.                             StartMember, ButtonObject,
  299.                                 GA_Text, "Button",
  300.                             EndMember,
  301.                             StartMember, ButtonObject,
  302.                                 GA_Text, "Button",
  303.                             EndMember,
  304.                             StartMember, ButtonObject,
  305.                                 GA_Text, "Button",
  306.                             EndMember,
  307.                             StartMember, ButtonObject,
  308.                                 GA_Text, "Button",
  309.                             EndMember,
  310.                             StartMember, ButtonObject,
  311.                                 GA_Text, "Button",
  312.                             EndMember,
  313.                             StartMember, ButtonObject,
  314.                                 GA_Text, "Button",
  315.                             EndMember,
  316.                             StartMember, ButtonObject,
  317.                                 GA_Text, "Button",
  318.                             EndMember,
  319.                             StartMember, ButtonObject,
  320.                                 GA_Text, "Button",
  321.                             EndMember,
  322.                             StartMember, ButtonObject,
  323.                                 GA_Text, "Button",
  324.                             EndMember,
  325.                         End,
  326.                         StartVGroup,
  327.                             StartMember, ButtonObject,
  328.                                 GA_Text, "Button",
  329.                             EndMember,
  330.                             StartMember, ButtonObject,
  331.                                 GA_Text, "Button",
  332.                             EndMember,
  333.                             StartMember, ButtonObject,
  334.                                 GA_Text, "Button",
  335.                             EndMember,
  336.                             StartMember, ButtonObject,
  337.                                 GA_Text, "Button",
  338.                             EndMember,
  339.                             StartMember, ButtonObject,
  340.                                 GA_Text, "Button",
  341.                             EndMember,
  342.                             StartMember, ButtonObject,
  343.                                 GA_Text, "Button",
  344.                             EndMember,
  345.                             StartMember, ButtonObject,
  346.                                 GA_Text, "Button",
  347.                             EndMember,
  348.                             StartMember, ButtonObject,
  349.                                 GA_Text, "Button",
  350.                             EndMember,
  351.                             StartMember, ButtonObject,
  352.                                 GA_Text, "Button",
  353.                             EndMember,
  354.                             StartMember, ButtonObject,
  355.                                 GA_Text, "Button",
  356.                             EndMember,
  357.                         End,
  358.                         StartVGroup,
  359.                             StartMember, ButtonObject,
  360.                                 GA_Text, "Button",
  361.                             EndMember,
  362.                             StartMember, ButtonObject,
  363.                                 GA_Text, "Button",
  364.                             EndMember,
  365.                             StartMember, ButtonObject,
  366.                                 GA_Text, "Button",
  367.                             EndMember,
  368.                             StartMember, ButtonObject,
  369.                                 GA_Text, "Button",
  370.                             EndMember,
  371.                             StartMember, ButtonObject,
  372.                                 GA_Text, "Button",
  373.                             EndMember,
  374.                             StartMember, ButtonObject,
  375.                                 GA_Text, "Button",
  376.                             EndMember,
  377.                             StartMember, ButtonObject,
  378.                                 GA_Text, "Button",
  379.                             EndMember,
  380.                             StartMember, ButtonObject,
  381.                                 GA_Text, "Button",
  382.                             EndMember,
  383.                             StartMember, ButtonObject,
  384.                                 GA_Text, "Button",
  385.                             EndMember,
  386.                             StartMember, ButtonObject,
  387.                                 GA_Text, "Button",
  388.                             EndMember,
  389.                         End,
  390.  
  391.                     EndMember,
  392.                 EndWindow;
  393.  
  394.                 /*  Object creation sucessful?
  395.                  */
  396.                 if( Win_Object )
  397.                 {
  398.                     /*  Open the window.
  399.                      */
  400.                     if( window = (struct Window *) CA_OpenWindow(Win_Object) )
  401.                     {
  402.                         ULONG wait;
  403.                         
  404.                         /* Obtain the window wait signal mask.
  405.                          */
  406.                         GetAttr( WINDOW_SigMask, Win_Object, &signal );
  407.  
  408.                         /* Input Event Loop
  409.                          */
  410.                         while( !done )
  411.                         {
  412.                             wait = Wait(signal|SIGBREAKF_CTRL_C);
  413.                             
  414.                             if (wait & SIGBREAKF_CTRL_C) done = TRUE;
  415.                             else
  416.  
  417.                             while ((result = CA_HandleInput(Win_Object,NULL)) != WMHI_LASTMSG)
  418.                             {
  419.                                 switch(result)
  420.                                 {
  421.                                     case WMHI_CLOSEWINDOW:
  422.                                         done = TRUE;
  423.                                         break;
  424.                                 }
  425.                             }
  426.                         }
  427.                     }
  428.  
  429.                     /* Disposing of the window object will
  430.                      * also close the window if it is
  431.                      * already opened and it will dispose of
  432.                      * all objects attached to it.
  433.                      */
  434.                     DisposeObject( Win_Object );
  435.                 }
  436.             }
  437.         }
  438.     }
  439.  
  440.     /* Close the classes.
  441.      */
  442.     if (LayoutBase) CloseLibrary( (struct Library *)LayoutBase );
  443.     if (ButtonBase) CloseLibrary( (struct Library *)ButtonBase );
  444.     if (WindowBase) CloseLibrary( (struct Library *)WindowBase );
  445.     
  446.     FreeArgs(args);
  447. }
  448.  
  449. #ifdef _DCC
  450. int wbmain( struct WBStartup *wbs )
  451. {
  452.         return( main( 0, NULL ));
  453. }
  454. #endif
  455.