home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
l
/
l-coll1.zip
/
TOOLLIBR.ZOO
/
ToolLibrary
/
src
/
Library_Demo2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-11-02
|
4KB
|
204 lines
#include <exec/types.h>
#include <proto/tool.h>
#include <exec/memory.h>
#include <graphics/gfxmacros.h>
#include <intuition/intuition.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
LONG Open_All(VOID);
VOID Ende(VOID);
VOID main(VOID);
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *ToolBase;
struct Screen *Screen;
struct Window *Window;
LONG MaxPos=11,MaxPos2=16;
struct PropInfo PInfo=
{
FREEVERT|AUTOKNOB,0,MAXBODY/3,0,MAXBODY/3,0,0,0,0,0,0
};
struct PropInfo PInfo2=
{
FREEHORIZ|AUTOKNOB,MAXBODY/4,0,MAXBODY/4,0,0,0,0,0,0,0
};
struct Image HImage;
struct Image HImage2;
struct Gadget Pot =
{
NULL ,15,11,20,120,GADGHCOMP,GADGIMMEDIATE|FOLLOWMOUSE,PROPGADGET,(APTR)&HImage,0,NULL,NULL,(APTR)&PInfo,1,0
};
struct Gadget Pot2 =
{
&Pot ,45,31,500,20,GADGHCOMP,GADGIMMEDIATE|FOLLOWMOUSE,PROPGADGET,(APTR)&HImage2,0,NULL,NULL,(APTR)&PInfo2,2,0
};
struct NewScreen Schirm=
{
0,0,640,256,2,2,1,HIRES,CUSTOMSCREEN,NULL,NULL,NULL,NULL
};
struct NewWindow Fenster=
{
0,10,640,246,0,1,CLOSEWINDOW|GADGETDOWN|MOUSEMOVE,
BORDERLESS|ACTIVATE|WINDOWCLOSE,
&Pot2,NULL,NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
CUSTOMSCREEN
};
UWORD Pattern[4]=
{
0xff00,0xff00,0x00ff,0x00ff
};
LONG Open_All(VOID)
{
IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0);
if(!IntuitionBase)
{
Ende();
return(1);
}
GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0);
if(!GfxBase)
{
Ende();
return(2);
}
ToolBase=OpenLibrary("tool.library",0);
if(!ToolBase)
{
Ende();
return(3);
}
Screen=OpenScreen(&Schirm);
if(!Screen)
{
Ende();
return(5);
}
Fenster.Screen=Screen;
Window=OpenWindow(&Fenster);
if(!Window)
{
Ende();
return(6);
}
return(0);
}
VOID Ende(VOID)
{
/* Wenn offen -> schlie▀en */
if(Window)
{
CloseWindow(Window);
ClearMenuStrip(Window);
};
if(Screen)CloseScreen(Screen);
if(GfxBase)CloseLibrary((struct Library *)GfxBase);
if(IntuitionBase)CloseLibrary((struct Library *)IntuitionBase);
if(ToolBase)CloseLibrary(ToolBase);
}
VOID _main()
{
LONG i,ENDE=1,Nr,a,aa,ai;
struct PropInfo *PInfo3;
struct RastPort *RP;
struct info msgInfo;
char buffer[90];
PInfo3=&PInfo;
if(!Open_All())
{
RP=Window->RPort;
SetDrMd(RP,JAM2);
i=GetPropPosH(&Pot2,MaxPos2);
a=GetPropPosV(&Pot ,MaxPos);
sprintf(buffer,"Vert : %3ld Horiz: %3ld",a,i);
Print(RP,buffer,1,10,150);
aa=a;
ai=i;
while(ENDE)
{
Wait(1L<<Window->UserPort->mp_SigBit);
/* Arbeitet ab, bis keine Events mehr */
while(EventAbfrage(Window,&msgInfo))
{
/* Verzweigt entsprechend der Events */
switch(msgInfo.NachrichtenArt)
{
case CLOSEWINDOW:ENDE=0;
break;
case MOUSEMOVE:
case GADGETDOWN:
{
Nr=((struct Gadget *)msgInfo.IAddress)->GadgetID;
i=GetPropPosH(&Pot2,MaxPos2);
a=GetPropPosV(&Pot ,MaxPos);
SetPropPosH(&Pot2,Window,MaxPos2,4,i);
SetPropPosV(&Pot ,Window,MaxPos ,3,a);
if(aa!=a||ai!=i)
{
sprintf(buffer,"Vert : %3ld Horiz: %3ld",a,i);
Move(RP,10,150);
ClearEOL(RP);
Print(RP,buffer,1,10,150);
aa=a;
ai=i;
}
}
}
}
}
for(i=0;i<=10;i++)
{
SetPropPosH(&Pot2,Window,MaxPos2,4,i);
SetPropPosV(&Pot ,Window,MaxPos ,3,i);
i=GetPropPosH(&Pot2,MaxPos2);
a=GetPropPosV(&Pot ,MaxPos);
sprintf(buffer,"Vert : %3ld Horiz: %3ld",a,i);
Move(RP,10,150);
ClearEOL(RP);
Print(RP,buffer,1,10,150);
Delay(50);
}
Delay(50);
Ende();
}
}