home *** CD-ROM | disk | FTP | other *** search
- // **********************************
- // HTMLtext-DEMO
- // (C)opyright by Dirk Holtwick, 1997
- // **********************************
-
- // This demo is kind of a WYSIWYG editor for HTML.
- // Just edit the string in the gadget and you will
- // see the effect in the same moment.
-
- // If you have problems, please report me the bug
- // and send me the text that leaded to confusion.
-
- /// Includes
- #include <workbench/startup.h>
- #include <clib/alib_protos.h>
- #include <proto/dos.h>
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include <proto/asl.h>
- #include <proto/utility.h>
- #include <proto/muimaster.h>
- #include <stdio.h>
- #include <string.h>
-
- // #include <mui/html_mcc.h>
- #include "include/HTMLtext_mcc.h"
-
- #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
-
- extern struct Library *SysBase;
-
- /* ATTENTION !!!
- ** HTMLtext.mcc makes use of recursion and so you
- ** have to take care, that there is always
- ** enough space on the stack. The more the better!
- */
-
- LONG __stack = 8192;
- ///
-
- /// Demotext
- #define DEMOTEXT \
- "<hr>This <i>is a <small>small</small> <big>Demo</big></i> of " \
- "the <b>HTMLtext class</b>.<hr>"
- ///
- /// Pointers
- APTR app;
- APTR window;
- APTR str;
- APTR html;
- APTR scroll;
- ///
-
- /// Main
- int main(int argc,char *argv[])
- {
- struct Library
- *IntuitionBase;
- int ret=RETURN_ERROR;
-
- if(IntuitionBase = OpenLibrary("intuition.library", 36))
- {
- struct Library *MUIMasterBase;
-
- if(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, 13))
- {
- ULONG signals;
- BOOL running = TRUE;
-
- // Load the text
- app = ApplicationObject,
- MUIA_Application_Title , "HTMLtext-DEMO",
- MUIA_Application_Version , "$VER: HTMLtext-DEMO 1.0 " __AMIGADATE__,
- MUIA_Application_Copyright , "(C)opyright by Dirk Holtwick 1997",
- MUIA_Application_Author , "Dirk Holtwick",
- MUIA_Application_Description, "Uses the HTMLtext.mcc to display text.",
- MUIA_Application_Base , "HTMLTEXTDEMO",
-
- SubWindow, window = WindowObject,
- MUIA_Window_Title, "HTMLtext-Demo © Dirk Holtwick, 1997",
- MUIA_Window_ID , MAKE_ID('D','E','M','O'),
- MUIA_Window_UseRightBorderScroller, TRUE,
- MUIA_Window_UseBottomBorderScroller, TRUE,
-
- WindowContents, VGroup,
-
- Child, scroll = ScrollgroupObject,
- MUIA_CycleChain, 1,
- MUIA_Scrollgroup_UseWinBorder, TRUE,
- MUIA_Scrollgroup_Contents, html = HTMLtextObject,
- TextFrame,
- MUIA_HTMLtext_Contents, DEMOTEXT,
- End,
- End,
-
- Child, str = StringObject,
- StringFrame,
- MUIA_CycleChain, 1,
- MUIA_String_MaxLen, 1024,
- End,
- End,
- End,
- End;
-
- if(app)
- {
- /*** generate notifies ***/
- DoMethod(window, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
- app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
-
- DoMethod(str,MUIM_Notify,MUIA_String_Contents,MUIV_EveryTime,
- html,3,MUIM_Set,MUIA_HTMLtext_Contents,MUIV_TriggerValue);
- /*
- DoMethod(str,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,
- html,3,MUIM_Set,MUIA_HTMLtext_Contents,MUIV_TriggerValue);
- */
- DoMethod(str,MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,
- window,3,MUIM_Set,MUIA_Window_ActiveObject,str);
-
-
- /*** ready to open the window ... ***/
- set(window,MUIA_Window_ActiveObject,str);
- set(window,MUIA_Window_DefaultObject,str);
-
- set(window,MUIA_Window_Open,TRUE);
-
- set(str, MUIA_String_Contents, DEMOTEXT);
- while (running)
- {
- switch(DoMethod(app,MUIM_Application_Input,&signals))
- {
- case MUIV_Application_ReturnID_Quit:
- running = FALSE;
- break;
- }
-
- if(running && signals)
- Wait(signals);
- }
-
- set(window, MUIA_Window_Open, FALSE);
-
- MUI_DisposeObject(app);
-
- ret = RETURN_OK;
- }
- else
- {
- puts("Could not open application!");
- ret = RETURN_FAIL;
- }
-
- CloseLibrary(MUIMasterBase);
- }
- else
- {
- puts("Could not open muimaster.library v13!");
- ret = RETURN_FAIL;
- }
-
- CloseLibrary(IntuitionBase);
- }
- else
- {
- puts("Could not open intuition.library v36!");
- ret = RETURN_FAIL;
- }
-
- return(ret);
- }
- ///
-
-