home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / mui / MCC_HTMLtext.lha / MCC_HTMLtext / Developer / C / Examples / HTMLtext-DEMO.c
Encoding:
C/C++ Source or Header  |  1997-02-28  |  4.1 KB  |  174 lines

  1. // **********************************
  2. // HTMLtext-DEMO
  3. // (C)opyright by Dirk Holtwick, 1997
  4. // **********************************
  5.  
  6. // This demo is kind of a WYSIWYG editor for HTML.
  7. // Just edit the string in the gadget and you will
  8. // see the effect in the same moment.
  9.  
  10. // If you have problems, please report me the bug
  11. // and send me the text that leaded to confusion.
  12.  
  13. /// Includes
  14. #include <workbench/startup.h>
  15. #include <clib/alib_protos.h>
  16. #include <proto/dos.h>
  17. #include <proto/exec.h>
  18. #include <proto/intuition.h>
  19. #include <proto/graphics.h>
  20. #include <proto/asl.h>
  21. #include <proto/utility.h>
  22. #include <proto/muimaster.h>
  23. #include <stdio.h>
  24. #include <string.h>
  25.  
  26. // #include <mui/html_mcc.h>
  27. #include "include/HTMLtext_mcc.h"
  28.  
  29. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  30.  
  31. extern struct Library *SysBase;
  32.  
  33. /*  ATTENTION !!!
  34. **  HTMLtext.mcc makes use of recursion and so you
  35. **  have to take care, that there is always
  36. **  enough space on the stack. The more the better!
  37. */
  38.  
  39. LONG __stack = 8192;
  40. ///
  41.  
  42. /// Demotext
  43. #define DEMOTEXT \
  44.     "<hr>This <i>is a <small>small</small> <big>Demo</big></i> of " \
  45.     "the <b>HTMLtext class</b>.<hr>"
  46. ///
  47. /// Pointers
  48. APTR app;
  49. APTR window;
  50. APTR str;
  51. APTR html;
  52. APTR scroll;
  53. ///
  54.  
  55. /// Main
  56. int main(int argc,char *argv[])
  57. {
  58.     struct   Library
  59.                 *IntuitionBase;
  60.     int      ret=RETURN_ERROR;
  61.  
  62.     if(IntuitionBase = OpenLibrary("intuition.library", 36))
  63.     {
  64.         struct Library *MUIMasterBase;
  65.  
  66.         if(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, 13))
  67.         {
  68.             ULONG signals;
  69.             BOOL running = TRUE;
  70.  
  71.             // Load the text
  72.             app = ApplicationObject,
  73.                 MUIA_Application_Title      , "HTMLtext-DEMO",
  74.                 MUIA_Application_Version    , "$VER: HTMLtext-DEMO 1.0 " __AMIGADATE__,
  75.                 MUIA_Application_Copyright  , "(C)opyright by Dirk Holtwick 1997",
  76.                 MUIA_Application_Author     , "Dirk Holtwick",
  77.                 MUIA_Application_Description, "Uses the HTMLtext.mcc to display text.",
  78.                 MUIA_Application_Base       , "HTMLTEXTDEMO",
  79.  
  80.                 SubWindow, window = WindowObject,
  81.                     MUIA_Window_Title, "HTMLtext-Demo © Dirk Holtwick, 1997",
  82.                     MUIA_Window_ID   , MAKE_ID('D','E','M','O'),
  83.                     MUIA_Window_UseRightBorderScroller, TRUE,
  84.                     MUIA_Window_UseBottomBorderScroller, TRUE,
  85.  
  86.                     WindowContents, VGroup,
  87.  
  88.                         Child, scroll = ScrollgroupObject,
  89.                             MUIA_CycleChain, 1,
  90.                             MUIA_Scrollgroup_UseWinBorder, TRUE,
  91.                             MUIA_Scrollgroup_Contents, html = HTMLtextObject,
  92.                                 TextFrame,
  93.                                 MUIA_HTMLtext_Contents, DEMOTEXT,
  94.                                 End,
  95.                             End,
  96.  
  97.                         Child, str = StringObject,
  98.                             StringFrame,
  99.                             MUIA_CycleChain, 1,
  100.                             MUIA_String_MaxLen, 1024,
  101.                             End,
  102.                         End,
  103.                     End,
  104.                 End;
  105.  
  106.             if(app)
  107.             {
  108.                 /*** generate notifies ***/
  109.                 DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  110.                     app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  111.  
  112.                 DoMethod(str,MUIM_Notify,MUIA_String_Contents,MUIV_EveryTime,
  113.                     html,3,MUIM_Set,MUIA_HTMLtext_Contents,MUIV_TriggerValue);
  114. /*
  115.                 DoMethod(str,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,
  116.                     html,3,MUIM_Set,MUIA_HTMLtext_Contents,MUIV_TriggerValue);
  117. */
  118.                 DoMethod(str,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,
  119.                     window,3,MUIM_Set,MUIA_Window_ActiveObject,str);
  120.  
  121.  
  122.                 /*** ready to open the window ... ***/
  123.                 set(window,MUIA_Window_ActiveObject,str);
  124.                 set(window,MUIA_Window_DefaultObject,str);
  125.  
  126.                 set(window,MUIA_Window_Open,TRUE);
  127.  
  128.                 set(str, MUIA_String_Contents, DEMOTEXT);
  129.                 while (running)
  130.                 {
  131.                     switch(DoMethod(app,MUIM_Application_Input,&signals))
  132.                     {
  133.                         case MUIV_Application_ReturnID_Quit:
  134.                             running = FALSE;
  135.                             break;
  136.                     }
  137.  
  138.                     if(running && signals)
  139.                         Wait(signals);
  140.                 }
  141.  
  142.                 set(window, MUIA_Window_Open, FALSE);
  143.  
  144.                 MUI_DisposeObject(app);
  145.  
  146.                 ret = RETURN_OK;
  147.             }
  148.             else
  149.             {
  150.                 puts("Could not open application!");
  151.                 ret = RETURN_FAIL;
  152.             }
  153.  
  154.             CloseLibrary(MUIMasterBase);
  155.         }
  156.         else
  157.         {
  158.             puts("Could not open muimaster.library v13!");
  159.             ret = RETURN_FAIL;
  160.         }
  161.  
  162.         CloseLibrary(IntuitionBase);
  163.     }
  164.     else
  165.     {
  166.         puts("Could not open intuition.library v36!");
  167.         ret = RETURN_FAIL;
  168.     }
  169.  
  170.     return(ret);
  171. }
  172. ///
  173.  
  174.