home *** CD-ROM | disk | FTP | other *** search
- /* ********************************************************************** */
- /* * WIZARD FILER EXAMPLE Version 1.01 Stefan Zeiger 21-Sep-91 * */
- /* ********************************************************************** */
-
-
- #include <intuition/intuition.h>
- #include <graphics/gfxbase.h>
- #include <string.h>
-
- /* Remember to include this file if you use WizardFiler(): */
- #include "WizardFiler.h"
-
-
- /* Declare the functions: */
- void _main();
- USHORT press_continue();
- void quit();
-
-
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase=NULL;
-
-
- struct IntuiMessage *your_message;
- struct Window *your_window;
-
-
- /* 80-Characters ROM font: */
- struct TextAttr your_font=
- {
- "topaz.font", /* Font Name */
- TOPAZ_EIGHTY, /* Font Height */
- FS_NORMAL, /* Style */
- FPF_ROMFONT /* Preferences */
- };
-
-
- /* ********************************************************************* */
- /* * Information for the boolean gadget "CONTINUE" * */
- /* ********************************************************************* */
-
- /* Values for a 8-letter box: */
- SHORT points8[]=
- {
- 0, 0,
- 76, 0,
- 76, 14,
- 0, 14,
- 0, 0
- };
-
- /* A border for a 8-letter box: */
- struct Border border8=
- {
- 0, 0, /* LeftEdge, TopEdge */
- 1, 2, JAM1, /* FrontPen, BackPen, DrawMode */
- 5, /* Count */
- points8, /* *XY */
- NULL /* *NextBorder */
- };
-
- struct IntuiText text_continue=
- {
- 3, 0, /* FrontPen, BackPen */
- JAM1, /* DrawMode */
- 7,4, /* LeftEdge, TopEdge */
- &your_font, /* *ITextFont, (Topaz, 80) */
- "CONTINUE", /* *IText */
- NULL /* *NextText */
- };
-
- struct Gadget gadget_continue=
- {
- NULL, /* *NextGadget */
- 16, 177, 78, 15, /* LeftEdge, TopEdge, Width, Height */
- GADGHNONE, /* Flags */
- GADGIMMEDIATE, /* Activation */
- BOOLGADGET, /* GadgetType */
- (APTR) &border8, /* GadgetRender */
- NULL, /* SelectRender */
- &text_continue, /* *GadgetText */
- NULL, /* MutualExclude */
- NULL, /* SpecialInfo */
- NULL, /* GadgetID */
- NULL /* UserData */
- };
-
-
- /* ********************************************************************* */
- /* * YOUR WINDOW * */
- /* ********************************************************************* */
-
- struct NewWindow your_new_window=
- {
- 0,0, /* LeftEdge, TopEdge */
- 640, 200, /* Width, Height */
- 0,1, /* DetailPen, BlockPen */
- CLOSEWINDOW| /* IDCMPFlags */
- GADGETDOWN,
- ACTIVATE| /* Flags */
- WINDOWDEPTH|
- WINDOWDRAG|
- WINDOWCLOSE|
- SMART_REFRESH,
- &gadget_continue, /* *FirstGadget */
- NULL, /* *CheckMark */
- (STRPTR) "WIZARD FILER 1.01 EXAMPLE", /* *Title */
- NULL, /* *Screen */
- NULL, /* *BitMap */
- 0,0, /* MinWidth, MinHeight */
- 0,0, /* MaxWidth, MaxHeight */
- WBENCHSCREEN /* Type */
- };
-
-
- /* ********************************************************************* */
- /* * TEXT: * */
- /* ********************************************************************* */
-
- struct IntuiText int_text=
- {
- 1, 0, /* FrontPen, BackPen */
- JAM2, /* DrawMode */
- 16, 9, /* LewftEdge, TopEdge */
- &your_font, /* *ITextFont */
- NULL, /* *IText */
- NULL /* *NextText */
- };
-
- char *text_string[19]=
- {
- " ",
- "WIZARD FILER EXAMPLE VERSION 1.01 21-Sep-91",
- "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
- "WizardFiler is an enhanced version of Anders Bjerin's 'FileWindow'.",
- "WizardFiler v1.01 was written by Stefan Zeiger of ! WIZARD WORKS !",
- "in 1991. It is in the PUBLIC DOMAIN with NO RIGHTS RESERVED. You",
- "may use it in all of your programs - commercial or not - and you",
- "do not even have to mention that you used it. You may alter the source",
- "code for your requirements and just do whatever you want to do with",
- "WizardFiler. And now try this demo and enjoy WizardFiler.",
- "",
- " Happy programming,",
- " Stefan.",
- "",
- "STANDARD MAIL : ! WIZARD WORKS !",
- " Stefan Zeiger",
- " Seligenstädter Weg 24",
- " D-W-8756 Kahl",
- "VOICE: (49)-6188-2525"
- };
-
-
- /* ******************* MAIN ******************** */
-
- void _main()
- {
- USHORT operation;
- UBYTE file[TOTAL_LENGTH];
- int temp;
-
- if((IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",33))==NULL) exit(0);
- if((GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",33))==NULL)
- {
- CloseLibrary((struct Library *)IntuitionBase);
- exit(0);
- }
-
- /* Open your window: */
- if((your_window=(struct Window *)OpenWindow(&your_new_window))==NULL)
- {
- CloseLibrary((struct Library *) IntuitionBase);
- CloseLibrary((struct Library *) GfxBase);
- exit(0);
- }
-
- /* Copy some text into file. This is optional, but very handy if you */
- /* want the WizardFiler() to start to look in a specific directory, or */
- /* device: */
- /* (If there is a file name in the string it will automatically appear */
- /* in the "File:" gadget, and the path in the "Drawer:" gadget.) */
- strcpy(file, "df0:");
-
- /* Fill your_window with text: */
- for(temp=1; temp < 19; temp++)
- {
- int_text.IText=text_string[temp];
- PrintIText(your_window->RPort, &int_text, 0, temp*8);
- }
-
- /* Wait: */
- press_continue();
-
- /* Clicking on the CLOSE WINDOW gadget to leave the while loop: */
- while(TRUE)
- {
- /* Clear your_window: */
- int_text.IText=text_string[0];
- for(temp=1; temp < 23; temp++)
- PrintIText(your_window->RPort, &int_text, 0, temp*8);
-
- /* WIZARD FILER !!! */
- operation=WizardFiler
- (
- "WIZARD FILER 1.01", /* Title */
- NULL, /* ToShow (all) */
- NULL, /* ToHide (none) */
- 0, 0, /* x, y position */
- NULL, /* Screen (none) */
- file /* file with path. */
- );
-
- int_text.IText="File name plus path:";
- int_text.FrontPen=1; /* Normal colour. */
- PrintIText(your_window->RPort, &int_text, 0, 8 );
-
- /* Write the filename and the path: */
- int_text.IText=file; /* file name and path. */
- int_text.FrontPen=3; /* Highlighted. */
- PrintIText(your_window->RPort, &int_text, 16, 16 );
-
- int_text.IText="Operation:";
- int_text.FrontPen=1; /* Normal colour. */
- PrintIText(your_window->RPort, &int_text, 0, 24 );
-
- switch(operation)
- {
- case LOAD: int_text.IText="LOAD"; break;
- case SAVE: int_text.IText="SAVE"; break;
- case CANCEL: int_text.IText="CANCEL"; break;
- case QUIT: int_text.IText="QUIT"; break;
- case PANIC: int_text.IText="PANIC"; break;
- default: int_text.IText="Something went terribly WRONG!";
- }
- int_text.FrontPen=3; /* Highlighted. */
- PrintIText(your_window->RPort, &int_text, 16, 32 );
-
- /* Draw the gadget again: */
- RefreshGadgets(&gadget_continue, your_window, NULL);
-
- /* Wait: */
- press_continue();
- }
- }
-
-
- /* Clean up before we leave: */
- void quit()
- {
- if(your_window) CloseWindow(your_window);
- if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
- if(GfxBase) CloseLibrary((struct Library *) GfxBase);
- exit(0);
- }
-
-
- /* This function simply waits for someone to click on the CONTINUE */
- /* or CLOSEWINDOW gadget: */
- USHORT press_continue()
- {
- ULONG class;
-
- while(TRUE)
- {
- Wait(1 << your_window->UserPort->mp_SigBit);
- if(your_message=(struct IntuiMessage *)GetMsg(your_window->UserPort))
- {
- class = your_message->Class;
- ReplyMsg((struct Message *)your_message);
- switch(class)
- {
- case CLOSEWINDOW:
- quit(); /* CLOSEWINDOW */
- case GADGETDOWN:
- return(1); /* CONTINUE */
- }
- }
- }
- }
-