home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
400-499
/
ff464.lzh
/
FileWindow
/
FileWindow2-Demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-03-09
|
8KB
|
203 lines
/**********************************************************************/
/* FileWindow2-Demo A.Bjerin/B.Schied Sept.89/Dez.90 */
/**********************************************************************/
#include <proto/all.h>
#include <string.h>
#include "FileWindow2.h"
extern USHORT FileWindow2(STRPTR,STRPTR,int,int,struct Screen *,STRPTR);
void showtext(UBYTE,UBYTE *,int,int), quit(void);
USHORT press_continue(void);
struct IntuitionBase *IntuitionBase;
struct IntuiMessage *your_message;
struct Window *your_window;
struct Rastport *rp;
struct TextAttr your_font= /* 80-Characters ROM font: */
{
"topaz.font", /* Font Name */
TOPAZ_EIGHTY, /* Font Height */
FS_NORMAL, /* Style */
FPF_ROMFONT /* Preferences */
};
/**/
/* Information for the boolean gadget "CONTINUE" */
/**/
SHORT points8[]=
{ /* Values for a 8-letter box: */
0, 0, 76, 0, 76,14, 0,14, 0, 0
};
struct Border border8= /* border for a 8-letter box: */
{
0, 0, /* LeftEdge, TopEdge */
3, 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 */
490, 177, 78, 15,/* LeftEdge, TopEdge, Width, Height */
GADGHBOX, /* Flags */
RELVERIFY | /* Activation */
GADGIMMEDIATE,
BOOLGADGET, /* GadgetType */
(APTR) &border8, /* GadgetRender */
NULL, /* SelectRender */
&text_continue, /* *GadgetText */
NULL, /* MutualExclude */
NULL,NULL,NULL /* SpecialInfo, GadgetID, UserData */
};
/**/
/* YOUR WINDOW */
/**/
struct NewWindow your_new_window=
{
0,0,
585, 200,
0,1,
CLOSEWINDOW | GADGETUP,
ACTIVATE | WINDOWDEPTH |
WINDOWDRAG | WINDOWCLOSE | SMART_REFRESH,
&gadget_continue, NULL,
(STRPTR) " FileWindow2-Demo B.Schied - Dez.1990 ",
NULL, NULL, 0, 0, 0, 0, WBENCHSCREEN
};
/**/
/* 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[]=
{
" ",
"FileWindow was created by Anders Bjerin first and was distributed as",
"public domain (AmigaLibDisk336) with NO RIGHTS RESERVED.",
" Mainly FileWindow has been modified by introducing 3 additional",
"device gadgets plus a rename gadget to increase its performance.",
"To destinguish between both versions I called mine 'FileWindow2'.",
" You may use 'FileWindow2' in your own programs, comercial or not.",
"Additionally you may alter the source code to fit your needs, and you",
"may spread it to anyone you like.",
"But in all these cases you MUST INCLUDE a short info about the work of",
"Anders Bjerin and my efforts visible for all users in your software.",
"IGNORING THIS YOUR PROGRAM CONTAINS STOLEN SOURCE CODE!",
"",
"If you have any questions, ideas, programs (PD or your own) etc,",
"or just want to say hello, PLEASE WRITE TO ME or Anders Bjerin",
"(Anders, I hope your adress is still being correct):",
"",
" Anders Bjerin Bernd Schied",
" Tulevagen 22 Vogelsbergstr. 1",
" 181 41 LIDINGO D-6200 Wiesbaden 68",
" SWEDEN Germany"
};
/**********************************************************************/
void _main(void)
{
USHORT operation;
UBYTE file[TOTAL_LENGTH];
int temp=0;
if((IntuitionBase=(struct IntuitionBase *)
OpenLibrary("intuition.library", 33))==NULL ) Exit(0);
if((your_window = (struct Window *)
OpenWindow(&your_new_window)) == NULL)
{ CloseLibrary((struct Library *) IntuitionBase); Exit(0); }
rp=your_window->RPort;
/* Copy some optional text into file. It's very handy if you want to */
/* start the FileWindow() to look in a specific directory, or device:*/
/* (If there's a file name in the string it will automat. appear in */
/* the "File:" gadget, and the path in the "Drawer: " gadget.) */
strcpy(file, "ram:");
for(temp=1; temp < 21; temp++) /* Fill your_window with text: */
{
showtext(1, text_string[temp], 0, temp*8-6);
}
press_continue(); /* Waits for a gadget clicking action */
while(TRUE)
{
showtext(1, text_string[0], 0, 167); /* Clear 2 text lines */
showtext(1, text_string[0], 0, 177);
operation=FileWindow2
(
" Load IFF picture ", /* Title */
NULL, /* Extension (none) */
150, 15, /* x, y position */
NULL, /* Screen (none) */
file /* path (with file) */
);
showtext(1, "File name plus path:", 0, 167);
showtext(3, file, 178, 167); /* Display filename and path: */
showtext(1, "Operation:", 0, 177);
switch(operation)
{
case TAKE: showtext(3, "TAKE", 178, 177); break;
case ABORT: showtext(3, "ABORT", 178, 177); break;
case PANIC: showtext(3, "PANIC", 178, 177); break;
default: showtext(3, "Something went terrible WRONG!",178,190);
}
press_continue(); /* Waits for a gadget clicking action */
}
}
/**/
/* This function only displays your text on your window */
void showtext(UBYTE color, UBYTE *text, int x, int y)
{
int_text.IText=text; int_text.FrontPen=color;
PrintIText(rp, &int_text, x, y);
}
/**/
/* This function waits for clicking on CONTINUE or CLOSEWINDOW gadget */
USHORT press_continue(void)
{
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 GADGETUP: return(1); /* CONTINUE */
}
}
}
}
/**/
void quit(void) /* Clean up before leave: */
{
if(your_window) CloseWindow(your_window);
if(IntuitionBase) CloseLibrary((struct Library *) IntuitionBase);
Exit(0);
}
/**/
/**********************************************************************/