home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / software / sviluppo / mcc_popph / developer / c / examples / popph_demo.c
Encoding:
C/C++ Source or Header  |  1999-08-17  |  5.0 KB  |  176 lines

  1.  
  2. /// Includes
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <stdlib.h>
  8. #include <exec/types.h>
  9. #include <libraries/mui.h>
  10. #include <libraries/asl.h>
  11. #include <proto/exec.h>
  12. #include <proto/muimaster.h>
  13.  
  14. #include "Popplaceholder_mcc.h"
  15.  
  16. LONG __stack = 18192;
  17.  
  18. #define SAVEDS __saveds
  19. #define ASM __asm
  20. #define REG(x) register __ ## x
  21.  
  22. //|
  23.  
  24. char VER[] = "$VER: PopplaceholderDemo 0.5 (27.07.99)";
  25.  
  26. /// CleanUp
  27. void CleanUp(void)
  28. {
  29.    if(MUIMasterBase)   {CloseLibrary(MUIMasterBase); MUIMasterBase = NULL; }
  30. }
  31. //|
  32. /// xget
  33. ULONG xget( Object *obj, int attr)
  34. {
  35. ULONG val;
  36.  
  37.         get( obj, attr, &val);
  38.         return( val );
  39. }
  40. //|
  41.  
  42. /// Main
  43.  
  44. static const char *PP_Table[] =
  45. {
  46.     "%s|normal",
  47.     "%g|highlight",
  48.     "%x|3-dimensional",
  49.     "%w|4-dimensional",
  50.     "Tag|Description",
  51.     "WWW|World Wide Web",
  52.     NULL
  53. };
  54.  
  55. struct  Library *MUIMasterBase  = NULL;
  56.  
  57. #define TextObj(a) TextObject, MUIA_Text_Contents, (a), MUIA_Font, MUIV_Font_Tiny, End
  58.  
  59.  
  60. int main(void)
  61. {
  62.  
  63. APTR app, window, pph;
  64.  
  65.  
  66.    if( !(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN)) )
  67.        {
  68.        printf("Can't open muimaster.library v%ld\n", MUIMASTER_VMIN);
  69.        CleanUp();
  70.        return(EXIT_FAILURE);
  71.        }
  72.  
  73.    app = ApplicationObject,
  74.             MUIA_Application_Title      , "Popplaceholder Demo",
  75. //            MUIA_Application_Version    , VERSTAG,
  76.             MUIA_Application_Copyright  , "©1999 Marcin Orlowski <carlos@amiga.com.pl>",
  77.             MUIA_Application_Author     , "Marcin Orlowski",
  78.             MUIA_Application_Base       , "POPPLACEHOLDERDEMO",
  79.             MUIA_Application_Window     ,
  80.                window = WindowObject,
  81.                         MUIA_Window_ID, 0,
  82.                         MUIA_Window_Title, "Popplaceholder demo",
  83.                         WindowContents,
  84.                               VGroup,
  85.                               Child, TextObject, MUIA_Text_Contents, "\033c\033b\033uPopplaceholder.mcc test", End,
  86.  
  87.                               Child, TextObj("\033cOrdinary object"),
  88.                               Child, pph = PopphObject,
  89.                                      MUIA_Popph_Array      , PP_Table,
  90.                                      MUIA_Popph_Contents   , "Something",
  91. //                                     MUIA_Popph_ReplaceMode, TRUE,
  92.                                      End,
  93.  
  94.  
  95.                               Child, TextObj("\033cAnd PopAsl alike"),
  96.                               Child, PopphObject,
  97.                                      MUIA_Popph_Contents   , "300 chars limit",
  98.                                      MUIA_Popph_Array      , PP_Table,
  99.                                      MUIA_Popph_PopAsl     , TRUE,
  100.                                      MUIA_Popph_Contents   , "RAM:",
  101.                                      ASLFR_DoSaveMode      , TRUE,
  102.                                      End,
  103.  
  104.  
  105.                               Child, TextObj("\033cAnother PopAsl (drawers only)"),
  106.                               Child, PopphObject,
  107.                                      MUIA_Popph_Array      , PP_Table,
  108.                                      MUIA_Popph_PopAsl     , TRUE,
  109.                                      MUIA_Popph_Contents   , "SYS:",
  110.                                      ASLFR_DrawersOnly     , TRUE,
  111.                                      End,
  112.  
  113.  
  114.                               Child, TextObj("\033cAlways 'classic' string (we Avoid others)"),
  115.                               Child, PopphObject,
  116.                                      MUIA_Popph_Array      , PP_Table,
  117.                                      MUIA_Popph_Avoid      , MUIV_Popph_Avoid_Textinput | MUIV_Popph_Avoid_Betterstring,
  118.                                      End,
  119.  
  120. /*
  121.                               Child, TextObject, MUIA_Text_Contents, "\033cLet's override the string object", End,
  122.                               Child, PopphObject,
  123.                                      MUIA_Popph_Array       , PP_Table,
  124.                                      MUIA_Popph_StringObject, StringObject, End,
  125.                                      End,
  126. */
  127.  
  128.  
  129.  
  130.                               End,
  131.                         End,
  132.  
  133.                  End;
  134.  
  135.  
  136.  
  137.       if(app)
  138.         {
  139.         DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  140.  
  141.  
  142.         set(window,MUIA_Window_Open,TRUE);
  143.  
  144.         if( xget(window, MUIA_Window_Open) )
  145.            {
  146.            ULONG sigs = 0;
  147.  
  148.            while(DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  149.              {
  150.              if(sigs)
  151.                {
  152.                sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  153.                if(sigs & SIGBREAKF_CTRL_C) break;
  154.                }
  155.              }
  156.            }
  157.         else
  158.            {
  159.            printf("Can't open window!\n");
  160.            }
  161.  
  162. //              printf( "Result string: '%s'\n", xget(pph, MUIA_Popph_Contents) );
  163.  
  164.         MUI_DisposeObject(app);
  165.         }
  166.       else
  167.         {
  168.         printf("Can't create application object\n");
  169.         DisplayBeep(NULL);
  170.         }
  171.  
  172.    CleanUp();
  173.    return(EXIT_SUCCESS);
  174. }
  175. //|
  176.