home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
326.lha
/
requester.library_v1.3
/
CustomList.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-12-30
|
7KB
|
264 lines
/*************************************************************************
This program opens and utilizes the requester.library in order to use
the new SPECIAL_REQ flag. This flag allows us to display a list of
strings in a requester with all the features of the FileIO requester.
Because version 0 of the library did not support this feature, but version
1.4 now does, we must open the library with version #1. Old applications
that do not know about SPECIAL_REQ will still work with this version of
the library. It is backward compatible as far as the disk IO features are
concerned.
If running this program from the CLI and you specify any argument on the
command (i.e. 1> TestFileIO blort ), then the window will open on a hires
screen. You can then see what the requester looks like in hires.
Manx compile:
cc +p CustomList.c
ln CustomList.o -lcl32
**************************************************************************/
#include <functions.h>
#include <exec/types.h>
#include <exec/io.h>
#include <stdio.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <graphics/gfxbase.h>
#include "FileIO.h"
/* extern long GetMsg(), OpenWindow(), IoErr(), OpenLibrary(); */
/* === System Global Variables ========================================== */
struct IntuitionBase *IntuitionBase = 0L;
struct GfxBase *GfxBase = 0L;
struct DosLibrary *DosBase = 0L;
struct RequesterBase *RequesterBase = 0L;
struct FileIO *myFileIO = 0L;
struct Window *myWindow = 0L;
struct Screen *myScreen = 0L;
ULONG argcount; /* Saves argc from main(). argcount==0, then run from WB. */
struct TextAttr topaz80_font;
VOID TestFileIO();
struct NewScreen NewFileIOScreen =
{
0, 0, /* LeftEdge, TopEdge */
640, 400, /* Width, Height */
2, /* Depth */
0, 1, /* Detail/BlockPens */
HIRES | LACE, /* ViewPort Modes (must set/clear HIRES as needed) */
CUSTOMSCREEN,
&topaz80_font, /* Font */
(UBYTE *)"Example FileIO Program's Screen",
0L, /* Gadgets */
0L, /* CustomBitMap */
};
struct NewWindow NewFileIOWindow =
{
168, 30, /* LeftEdge, TopEdge */
303, 145, /* Width, Height */
-1, -1, /* Detail/BlockPens */
MOUSEBUTTONS | CLOSEWINDOW,
/* IDCMP Flags */
WINDOWDRAG | WINDOWDEPTH | SIZEBRIGHT | SMART_REFRESH |
WINDOWCLOSE | ACTIVATE | NOCAREREFRESH,
/* Window Specification Flags */
0L, /* FirstGadget */
0L, /* Checkmark */
(UBYTE *)"FileIO SPECIAL_REQ Example", /* WindowTitle */
0L, /* Screen */
0L, /* SuperBitMap */
303, 145, /* MinWidth, MinHeight */
600, 200, /* MaxWidth, MaxHeight */
WBENCHSCREEN,
};
VOID information();
UBYTE button_text[] = {" About"};
/************************ MAIN ROUTINE *****************************/
VOID main(argc, argv)
LONG argc;
char **argv;
{
LONG class;
USHORT code;
struct IntuiMessage *message;
BOOL end;
argcount = argc;
if (!(IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library", 0L)))
exit_program("FileIO Demo: No intuition library. \n", 1L);
if (!(GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 0L)))
exit_program("FileIO Demo: No graphics library. \n", 2L);
/* NOW OPEN THE REQUESTER LIBRARY, Version 1 */
if (!(RequesterBase = (struct RequesterBase *)OpenLibrary("requester.library", 1L)))
exit_program("FileIO Demo: No requester library. \n", 4L);
if (argv)
{
/* OK, we started from CLI */
if (argc > 1)
{
if (myScreen = OpenScreen(&NewFileIOScreen))
{
NewFileIOWindow.Screen = myScreen;
NewFileIOWindow.Type = CUSTOMSCREEN;
}
}
}
if (!(myWindow = (struct Window *) OpenWindow( &NewFileIOWindow ) ))
exit_program("FileIO Demo: Null Window.\n", 5L);
if (!(myFileIO = GetFileIO() ))
exit_program("FileIO Demo: No FileIO 1.\n", 6L);
/* Set up the XY co-ordinates where the requester should open */
myFileIO->X = 6;
myFileIO->Y = 11;
/* Set default colors and DrawMode */
myFileIO->DrawMode = JAM2;
myFileIO->PenA = 1;
myFileIO->PenB = 0;
myFileIO->FileIOText = button_text;
myFileIO->FileIORoutine = (APTR)information; /* pointer to function */
SetFlag(myFileIO->Flags, SPECIAL_REQ );
/* pretty easy to set up, eh? */
end = FALSE;
while (end == FALSE)
{
WaitPort(myWindow->UserPort);
while (message = ( struct IntuiMessage *)GetMsg(myWindow->UserPort))
{
class = message->Class;
code = message->Code;
ReplyMsg(message);
switch (class)
{
case CLOSEWINDOW:
end = TRUE;
break;
case MOUSEBUTTONS:
if( code == SELECTDOWN )
TestFileIO(myFileIO, myWindow);
break;
default:
break;
}
}
}
exit_program( 0L, 0L);
}
exit_program( error_words, error_code ) /* All exits through here. */
char error_words;
ULONG error_code;
{
if( argcount && error_words ) puts( error_words );
if (myFileIO) ReleaseFileIO(myFileIO);
if (myWindow) CloseWindow(myWindow);
if (myScreen) CloseScreen(myScreen);
if (IntuitionBase) CloseLibrary(IntuitionBase);
if (GfxBase) CloseLibrary(GfxBase);
if (DosBase) CloseLibrary(DosBase);
if (RequesterBase) CloseLibrary(RequesterBase);
exit( error_code );
}
UBYTE string[10][14] = {
{"This is One"},
{"This is Two"},
{"This is Three"},
{"This is Four"},
{"This is Five"},
{"This is Sex"},
{"This is Seven"},
{"This is Eight"},
{"This is Nine"},
{"This is Ten"},};
VOID TestFileIO(fileio, wind)
struct FileIO *fileio;
struct Window *wind;
{
UBYTE *address;
UBYTE c;
SHORT err;
/* This function makes the list of strings to display, and calls DoFileIO().
We have set the SPECIAL_REQ flag of FileIO. */
NewEntryList( fileio ); /* frees any previous list */
for( c=0; c<10; c++ )
{
err = AddEntry( c+1, string[c], fileio );
if( err < 0 ) AutoMessage("Out of memory for this string", wind );
}
address = DoFileIO(fileio, wind);
if( address == fileio->FileName )
{
/* If user was positive and no error, display the name */
AutoMessage( fileio->FileName, wind);
if( fileio->FileSize == -1 )
{
/* If user typed in string not in the list, indicate this */
AutoMessage( "string not in the list", wind);
}
if( fileio->Errno == ERR_APPGADG )
{
AutoMessage( "Cancelled by custom routine.", wind);
}
}
if (!address) AutoMessage("Error in operation", wind);
if (address==-1) AutoMessage("Cancelled operation", wind);
if (address==-2) AutoMessage("Library in use", wind);
}
VOID information( req, wind, fileio )
struct Requester *req;
struct Window *wind;
struct FileIO *fileio;
{
AutoMessage("The north end of a south facing chicken", wind );
}